Reputation: 41
I’m working on a project where I preprocess code and add some definitions at the beginning. To maintain accurate line numbers for error reporting, I’m using the #line directive. According to the Microsoft documentation, #line 0 is valid, and it compiles correctly with MSVC. However, IntelliSense in Visual Studio flags it as an error with the message ‘invalid line number.’
From Microsoft
The digit-sequence value can be any integer constant within the range from 0 to 2147483647, inclusive. Macro replacement can be used on the preprocessing tokens, but the result must evaluate to the correct syntax.
Project compiles perfectly with no error report or warning from compiler, And it also reports the correct line numbers, Only thing that concerns me is the error from IntelliSense :
Severity Code Description : Error (active) E0034 invalid line number
Has anyone else encountered this issue? Is using #line 0 safe and reliable in MSVC, or should I avoid it due to potential undefined behavior? Any insights or alternative solutions would be greatly appreciated.
Upvotes: 0
Views: 76