Can't access constant #defined in C

This is the C program I used, in the header file I define the offset:

#define LDR_DATA_PATHFILENAME_OFFSET    0x24    // MODULE_ITEM.PathFileName

      

Later in the program, I use it like:

pImageName = (PUNICODE_STRING)( ((DWORD)(pUserModuleListPtr)) + 
(LDR_DATA_PATHFILENAME_OFFSET-dwOffset));

      

When checking the LDR value, I get CXX0017: Error: Symbol "LDR_DATA_PATHFILENAME_OFFSET" was not found. Erm, its definition, it compiles, but it cannot access the value! What am I doing wrong?

0


a source to share


4 answers


I am assuming that you are debugging your application because you said "check": The character constants are replaced with their values ​​at compile time. During work, you can no longer see them.



+7


a source


Are you sure your header file is included? Easy check - copy the #define file from the header file to the beginning of your C file.



Double check the #ifndef protection in the header file.

+3


a source


Look for an option in your compiler to dump the preprocessed source so you can see what's going on. Perhaps your symbol got undefined, or your header isn't included correctly as you expect.

0


a source


Are you using an old C compiler? You are using a C ++ style comment // instead of a C style comment // * * /. Older C compilers do not recognize //.

-1


a source







All Articles