tags:

views:

183

answers:

4

This is a C program that I was using, in the header file I define an offset:

#define LDR_DATA_PATHFILENAME_OFFSET    0x24    // MODULE_ITEM.PathFileName

Later in the program I use it as following:

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

When inspecting the value of LDR i get an CXX0017: Error: symbol "LDR_DATA_PATHFILENAME_OFFSET" not found. Erm, its defined, it compiles, but yet it can't access the value! What am I doing wrong?

+7  A: 

I am assuming that you are debugging your application because you said "inspecting": Symbolic constants are substituted by its values at compile time. At runtime you can´t see them anymore.

fbinder
While it's not clear where he's "inspecting" the variable, it's clearly a compile-time error that he pasted.
Dan Olson
A: 

Find the option in your compiler to dump preprocessed source so you can see what's really going on. Your symbol may have gotten undefined, or your header isn't included correctly as you expect.

Dan Olson
A: 

Are you using an older C compiler? You're using a C++ style comment // instead of the C style comment of /* */. Older C compilers won't recognize the //.

John Deters
No, its a new compiler.
flavour404
+3  A: 

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

Double check the #ifndef guards in your header file.

Igor Krivokon
Whats the #ifndef statement?Little confused. I am examining the #define at run time, so yes I now know that the value is no longer available for inspection.I'm annoyed with C++ strict typing, try to pass a char into a function, but as soon as I do that it appears that my function call is getting mangled, and I can see no reason why?!
flavour404
#ifndef is commonly used as an include guard, see http://en.wikipedia.org/wiki/Include_guardIf your header file has wrong #ifndef, it can prefent the header file from being loaded. This is just a wild guess, I've seen it a couple of times.More important - did you try to copy and insert the same define to the C++ file you're debugging?
Igor Krivokon