everparse icon indicating copy to clipboard operation
everparse copied to clipboard

EverParse generated code should compile /W4 /WX clean

Open Alan-Jowett opened this issue 3 years ago • 2 comments

EverParse generated code should compile /W4 /WX clean.

Code in https://github.com/microsoft/ebpf-for-windows/ is expected to compile with /W4 /WX, but the code generated by EverParse is not /W4 clean.

Alan-Jowett avatar Apr 04 '22 17:04 Alan-Jowett

hi @Alan-Jowett

When building EverParse generated code with the Visual C/C++ compiler, we use the following settings

/W4 /WX /wd4127 /wd4204 /wd4100 /wd4201

Where, we suppress:

  • error C4100: unreferenced formal parameter, since in some optimized validators the input buffer does not need to be read at all (just a size check will do). It may be possible to generate code with a dummy call to a macro, e.g., UNREFERENCE_PARAMETER(x) or something like that, which may be a replacement for suppressing error 4100.

As for the others, our generate code does pervasively use the features that these warnings complain about. I don't see an easy way for our code generator to not use these features.

  • error C4127: conditional expression is constant
  • error C4204: nonstandard extension used: non-constant aggregate initializer
  • error C4201: nonstandard extension used: nameless struct/union

nikswamy avatar Apr 05 '22 23:04 nikswamy

C4100 (unreferenced formal parameter) should now be avoided with #102.

tahina-pro avatar Oct 02 '23 17:10 tahina-pro