-
Notifications
You must be signed in to change notification settings - Fork 101
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
baremetal: amalgamated header missing #include <stdarg.h> #193
Comments
Thanks for the detailed write-up. Indeed the amalgamation tool is removing repeated includes to keep compilation times reduced. And indeed the tool is dumb and cannot detect |
Makes sense. Thanks again! |
@danngreen The fixes were merged to master. I will keep this issue open (and biojppm/c4core#63 as well) until there is a QEMU in the CI in either repo proving that code does indeed work with arm-none-eabi. For now, in the absence of such proof, please let me know if you find any other problem or quirk. Thanks! |
The output of the amalgamate.py script produces a file which contains all instances of
#include <stdarg.h>
commented out, except for the first one. This would be fine except that the first instance of#include <stdarg.h>
is inside a#ifdef C4CORE_SINGLE_HDR_DEFINE_NOW
block, but the second#include <stdarg.h>
(which is imported from src/c4/yml/parse.hpp) is not within a#ifdef C4CORE_SINGLE_HDR_DEFINE_NOW
or#ifdef RYML_SINGLE_HDR_DEFINE_NOW
block.Therefore, when including the amalgamated output into a file without a preceding
#define RYML_SINGLE_HDR_DEFINE_NOW
, theva_list
symbol is used without being declared, and produces an error (on at least some compilers). This is of course regardless of whether or not another compilation unit included the amalgamated output withRYML_SINGLE_HDR_DEFINE_NOW
defined, since it's a compilation error, not a linker error.On the arm-none-eabi-gcc toolchain, I get this error, but compiling with clang++ 13 seems to work. I don't know the reason for the difference, but I'm guessing it's why this hasn't been detected until now.
Here's an easy way to replicate: (this is assuming the gcc-arm embedded toolchain 10.3 is installed and on $PATH):
Produces this error:
Including
<stdarg.h>
beforeryml_all.hpp
works:I would assume all standard library headers will have include guards, so I'm guessing the reason to ignore duplicate includes is to speed up compile time when using the amalgamated header? I can see it being tricky to get the python script to detect which
#includes
are within#ifdef
blocks, and comment out accordingly, so I don't have a proposal for an easy, general solution. It's not a difficult work-around to include<stdarg.h>
manually. But I did want to bring it up since it might help someone else also using this project in the single-header method with the gcc arm compiler (since it is, IMO an excellent tool for using yaml on embedded systems).Thanks for you hard work on this project.
The text was updated successfully, but these errors were encountered: