Discussion about generated C code #53
Replies: 6 comments 6 replies
-
Yeah, my original suspicion was correct. It's a GCC "behavior", so to speak; clang does not do such thing with its header files. |
Beta Was this translation helpful? Give feedback.
-
I have tested both GCC and Clang with the following Yeah, I deleted clang -o helloworld helloworld.c -Wall -fwrapv -g -lm -s
gcc -o helloworld helloworld.c -Wall -fwrapv -g -lm -s |
Beta Was this translation helpful? Give feedback.
-
The C generate code follow rules from the C standard. For example, the standard say if you need to use
Because the following headers are exceptions, and are always included in any generated C code, as they are required for Nelua primitives types:
But yea, the Nelua compiler could include them only when really used as a small enhancement, but in general, in usual applications, they will be always included anyway. |
Beta Was this translation helpful? Give feedback.
-
I've improved the C code generation to include those headers only when required in c0fdc42 and 33d36d9 In summary now:
|
Beta Was this translation helpful? Give feedback.
-
I have just tested it; it's more than awesome, kudos! So...when you are going to write "The Design and Implementation of Nelua"? I must have it in my collection! 😆 |
Beta Was this translation helpful? Give feedback.
-
About the use of We do know though that some compilers use a plain In my humble opinion, I would not want to include an entire header file for using a single thing, such as Personally, what I would do would be to undefined Thoughts? |
Beta Was this translation helpful? Give feedback.
-
I run the
examples/helloworld.nelua
and I have noticed in generated C code the following header files:I have looked for the use of
bool
anywhere in the generated code and could not find it in there and wondered why it was even added there 🤔Also, if we open
<inttypes.h>
header file, we will see that it calls<stdint.h>
as well; so, we don't need to add it during generating code.The same goes with
<stddef.h>
which<stdio.h>
includes at the very first lines of it.I know
ifdef
guards they take place and ignore the extra calls, but would it hurt if we clean the generated code?...unless it's something that is only part of GCC, the compiler of my personal choice.
Now that's interesting; let me check by using Clang instead of GCC.
Beta Was this translation helpful? Give feedback.
All reactions