Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preprocessor: undefined variables aren't implicitly converted to zero #534

Closed
Tracked by #77
ForNeVeR opened this issue Jan 27, 2024 · 0 comments · Fixed by #613
Closed
Tracked by #77

Preprocessor: undefined variables aren't implicitly converted to zero #534

ForNeVeR opened this issue Jan 27, 2024 · 0 comments · Fixed by #613
Labels
area:preprocessor Related to C preprocessor good-first-issue An issue considered simple enough for new contributors kind:feature New feature or request status:help-wanted Open for contributors

Comments

@ForNeVeR
Copy link
Owner

Consider this valid C program:

#if FOO
int a = 1;
#endif

It is expected to generate an empty C file (an undefined variable evaluates to zero).

Currently, it will fail with a stack trace:

Unhandled exception. Cesium.Core.PreprocessorException: Invalid integer constant expression
   at Cesium.Preprocessor.MacroExtensions.AsBoolean(String macroValue) in G:\Projects\Cesium\Cesium.Preprocessor\MacroExtensions.cs:line 14
   at Cesium.Preprocessor.CPreprocessor.EvaluateExpression(IEnumerable`1 expressionTokens) in G:\Projects\Cesium\Cesium.Preprocessor\CPreprocessor.cs:line 753
   at Cesium.Preprocessor.CPreprocessor.ProcessDirective(IEnumerable`1 directiveTokens) in G:\Projects\Cesium\Cesium.Preprocessor\CPreprocessor.cs:line 616
   at Cesium.Preprocessor.CPreprocessor.GetPreprocessingResults()+MoveNext() in G:\Projects\Cesium\Cesium.Preprocessor\CPreprocessor.cs:line 77
   at Cesium.Preprocessor.CPreprocessor.GetPreprocessingResults()+System.Threading.Tasks.Sources.IValueTaskSource<System.Boolean>.GetResult()
   at Cesium.Preprocessor.CPreprocessor.ProcessSource() in G:\Projects\Cesium\Cesium.Preprocessor\CPreprocessor.cs:line 37
   at Cesium.Preprocessor.CPreprocessor.ProcessSource() in G:\Projects\Cesium\Cesium.Preprocessor\CPreprocessor.cs:line 37
   at Cesium.Compiler.Compilation.Preprocess(String inputFilePath, CompilationOptions compilationOptions) in G:\Projects\Cesium\Cesium.Compiler\Compilation.cs:line 91     
   at Cesium.Compiler.Compilation.GenerateCode(AssemblyContext context, String inputFilePath) in G:\Projects\Cesium\Cesium.Compiler\Compilation.cs:line 97
   at Cesium.Compiler.Compilation.Compile(IEnumerable`1 inputFilePaths, String outputFilePath, CompilationOptions compilationOptions) in G:\Projects\Cesium\Cesium.Compiler\Compilation.cs:line 40
   at Program.<>c.<<<Main>$>b__0_0>d.MoveNext() in G:\Projects\Cesium\Cesium.Compiler\Main.cs:line 39
--- End of stack trace from previous location ---
   at Cesium.Compiler.CommandLineParser.<>c__DisplayClass0_0.<<ParseCommandLineArgs>b__1>d.MoveNext() in G:\Projects\Cesium\Cesium.Compiler\CommandLineParser.cs:line 37   
--- End of stack trace from previous location ---
   at Cesium.Compiler.CommandLineParser.ParseCommandLineArgs(String[] args, ICompilerReporter reporter, Func`2 worker) in G:\Projects\Cesium\Cesium.Compiler\CommandLineParser.cs:line 18
   at Program.<Main>$(String[] args) in G:\Projects\Cesium\Cesium.Compiler\Main.cs:line 6
   at Program.<Main>(String[] args)
@ForNeVeR ForNeVeR added kind:feature New feature or request status:help-wanted Open for contributors area:preprocessor Related to C preprocessor good-first-issue An issue considered simple enough for new contributors labels Jan 27, 2024
@ForNeVeR ForNeVeR changed the title Preprocessor: string-valued macros no longer work properly Preprocessor: undefined variables aren't implicitly converted to zero Jan 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:preprocessor Related to C preprocessor good-first-issue An issue considered simple enough for new contributors kind:feature New feature or request status:help-wanted Open for contributors
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant