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

Build strclr and strreplacechar when enabling newlib #157

Merged
merged 2 commits into from
Apr 21, 2020

Conversation

doragasu
Copy link

These functions are not part of the C standard library (and not included in newlib) and thus must be built when newlib is enabled. Otherwise the library fails to build because of these symbols missing.

I have just moved them out of the #if (ENABLE_NEWLIB == 0) blocks.

@doragasu
Copy link
Author

Pushed another commit that fixes implicit declarations of functions removed when defining ENABLE_NEWLIB 1. This happens for example when:

  • In your program using newlib, you #include <string.h> and use for example strcpy()`
  • The string.h file gets included, and since declaration for strcpy() has been removed, you get an implicit declaration warning.

The fix uses #include_next GCC extension. It also adds an #include <string.h> to the src/pal.cfile, since in the standard C library,memcpy()is defined instring.h` and thus was not getting included when enabling newlib.

Copy link
Owner

@Stephane-D Stephane-D left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks ok :)

Copy link
Owner

@Stephane-D Stephane-D left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does #include_next exactly does ?
Also is it possible to keep STRING_H by default for SGDK and just replace it with SGDK_STRING_H if NEWLIB is used ? I think it would be better.

@doragasu
Copy link
Author

#include_next is a GCC extension (not standard C unfortunately). In the undesirable case when several include files have the same name, when your program makes the #include <file.h>, only one of them gets included (depending on the compiler installation, the -I switches, etc. In this case, what the #include_next does, is including the next file in the chain with the same name.

So, in this case, for example, my application does #include <string.h>, and the string.h file in SGDK gets included. But I wanted stuff from the newlib string.h file, so the #include_next directive will include for me the string.h file from newlib.

I can make the change to the include guards to keep the _SGDK_STRING_H_. It will make the #if directives a bit more tangled, but should not be a problem.

Thanks for review!

@doragasu
Copy link
Author

Done! (forced pushed).
It might look a bit dirty because of the #undef _STRING_H_, but if you want to preserve the _STRING_H_ guard name, this is the best approach I could think of.

Copy link
Owner

@Stephane-D Stephane-D left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ready to be merged 👍
I want to add you as author of this unit, you can do it yourself by modifying the unit header but i can also do it (to avoid you modifying again just for that) in which case i need to know how you want your name to appear :)

@Stephane-D Stephane-D merged commit 9801b5a into Stephane-D:master Apr 21, 2020
@doragasu
Copy link
Author

Thanks!

I usually write "Jesús Alonso (doragasu)"

If you prefer avoiding non-english characters, you can use "Jesus Alonso (doragasu)"

Repository owner deleted a comment from doragasu Apr 21, 2020
@Stephane-D
Copy link
Owner

Ok perfect, i will use the non-english characters version if you don't mind :)

@doragasu doragasu deleted the devel_newlib branch April 24, 2020 15:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants