www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 24639] New: ImportC: defines of negative constants not

https://issues.dlang.org/show_bug.cgi?id=24639

          Issue ID: 24639
           Summary: ImportC: defines of negative constants not detected
                    for enum conversion
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: schveiguy gmail.com

file2.c:
#define blah -1
#define blah2 (-1)
#define blah3 (0 - 1)

file1.d:
import file2;

unittest
{
   assert(blah == -1); // can't find blah
   assert(blah2 == -1); // can't find blah2
   assert(blah3 == -1); // OK!
}

I think the issue is that the parser does not see the `-` sign as a number, and
so skips this definition. But it does work for an expression that starts with a
number inside parentheses.

--
Jun 29