#define GETADDR_FOR(a) if (!(a = (#_#a)GetProcAddress(h, "/""#a"/""))) -iFail Īnd again, while I'd APPRECIATE an insight into what silly mistake I've made, it would make my day to have a utility that would show me the error of my ways, by simply plugging in my macro. It doesn't work (my // comment is just to prevent text formatting in the message). If you have ever used C/C++ preprocessor macros, you know that there are some annoying and. Macro invocations appearing in that expansion are left unchanged. The Expansion Order Hierarchy The Macro Definition Hierarchy. Well this is the best I've come up with so far. Some languages, such as C and C++, provide a way to define and invoke preprocessor. So let's say I'd like to replace each line like the above with a macro, like this. gcc version and make settings: gcc version gcc (Ubuntu 9.3.0-17ubuntu120.04) 9.3.0 make settings CC gcc WARNINGS -Wer. define AAA 1 define CCC AAA define AAA 'hello' sizet x sizeof CCC This code will expand to 'hello', not 1. I am trying to use a macro but gcc is not happy and I am out of ideas. if (!(hexdump = (_hexdump)GetProcAddress(h, "hexdump"))) -iFail The expansion of CCC is always (AAA+BBB) its just that the result of macro expansion is rescanned for more macros to expand, at which point AAA and BBB turn into 1 and 10, respectively. ![]() If GetProcAddress() fails, a failure counter in incremented. They differ mostly in what they look like when they are used. So I want to use a define to simplify assignments of a long long list of function pointers.įor example, In the code statement below, 'hexdump' is the name of a typedef'd function point, and is also the name of the function, while _hexdump is the name of the typedef. The way I've set things up, the function pointers have the same nanes as the exported functions, and the typedef(s) used to prototype them have the same names, but with a prepended underscore. But really the bigger question is whether there is any utility someone could recommend, to quickly display what a macro is actually doing? It seems like even the slow trial and error process would go much faster if I could see what is wrong.Ĭurrently, I'm dynamically loading a long list of functions from a DLL I made. The example below runs as expected, but it compiles with warnings from the MACRO expansion. ![]() Im trying to create a macro that handles them both. I'll post my current dilemma below and any help is appreciated. My TLV structure can hold string or integer. ![]() It seems I often spend way too much time trying to get a #define macro to do exactly what i want.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |