Closed asmwarrior closed 7 months ago
__INTELLISENSE__
isn't a feature. It's just a check for the IDE (Visual Studio) I like to use. Said IDE doesn't like the "TPP(...)" namespace macro (which adds a TPP_
prefix to various symbols), so I hide it in a couple of spots as a hacky work-around. It is never defined during compilation.
Line/column information is always available, and there are 2 different values you can (easily) query:
TPPLexer_TRUE_LC()
: The actual origin of the current token (you probably don't want this one, since it can point into a macro definition)TPPLexer_LC()
: The current souce location, as also returned the special __LINE__
and __COLUMN__
macrosNote that these *_LC()
functions return 0-based numbers, so if you want to display them to a user, you'll have to add +1.
Example:
struct TPPLCInfo lc;
TPPLexer_LC(&lc);
printf("%s:%d:%d: Here\n", TPPLexer_FILE(NULL), (int)lc.lc_line + 1, (int)lc.lc_col + 1);
You can also enumerate the file/line/column info for every macro on the macro-expansion (or even keep going and print #include
locations from the include-stack). An example of this can be found in the code here (where it's used for generating tracebacks when warnings are printed):
https://github.com/GrieferAtWork/tpp/blob/31ccfa65eb7543ce4c0db654c5c4b2082f1141fb/src/tpp.c#L15362
@asmwarrior I've now extended the "advanced" sample to print token file positions. When inside of a macro, it also prints the name of the currently top-most macro, as well as where the token currently being generated originates from.
__INTELLISENSE__
isn't a feature. It's just a check for the IDE (Visual Studio) I like to use. Said IDE doesn't like the "TPP(...)" namespace macro (which adds aTPP_
prefix to various symbols), so I hide it in a couple of spots as a hacky work-around. It is never defined during compilation.
OK, thanks for the explanation. I think this should be document somewhere, so others won't ask similar question again.
Also, thanks for the demo code in the "advanced" samples, I learned a lot from that code.
Can you add some comments about the macro definition __INTELLISENSE__
?
This is not known from the non msvc people.
See document here: Microsoft-specific predefined macros
Hi, I see some code
I don't really understand what dose the
__INTELLISENSE__
mean, so I think some document or sample code about this feature is needed. Thanks.