Menu

compilation issue with agg_span_gradient_contour.h

Coconut
2017-11-15
2017-11-23
  • Coconut

    Coconut - 2017-11-15

    When building gradients_ountour.cpp using cmake, I encountered the following error message

    In file included from /c/dr/svg/agg-2.4/examples/gradients_contour.cpp:25:0:
    /c/dr/svg/agg-2.4/include/agg_span_gradient_contour.h:37:18: error: expected unqualified-id before numeric constant
    #define infinity 1E20

    My build environment is cygwin64 with

    $ gcc --version
    gcc (GCC) 6.4.0
    Copyright (C) 2017 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions. There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

    I renamed infinity to MY_INFINITY and replaced its occurance in the file and fixed the issue. Not sure it may had anything to do with macro overshadoing anything.

    IMO, this macro should be undefined since such name can easily cause problems.

     
  • Jim Barry

    Jim Barry - 2017-11-23

    I quite agree. By convention, preprocessor symbols should be in uppercase, and introducing such a symbol to represent a very large number seems especially inadvisable when one could just use FLT_MAX (or std::numeric_limits<float>::max). The file gradients_contours.cpp contains more lowercase preprocessor symbols, which I have either renamed to uppercase or replaced with const variables. SVN revision 128. Thanks for reporting the issue.

     

Log in to post a comment.