Skip to content

lwip: Renamed header files to have lwip prefix to avoid name conflicts #3833

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

Closed
wants to merge 1 commit into from

Conversation

geky
Copy link
Contributor

@geky geky commented Feb 23, 2017

Currently conflicts with standard header errno.h. Results in a compilation error for IAR if user attempts to assign the standard errno.

Caused by these prs:

As far as I can tell the only solution is to rename the problematic file (lwip/errno.h). Let me know if anyone can think of another solution.

This pr updates all lwip header files with the lwip prefix for consistency. This is already the case for source files for unrelated issues with IAR.

Script (yes I should learn perl...):

PREFIX=lwip
FILES=$(find features/FEATURE_LWIP/lwip-interface/lwip/src/include/lwip -type f -a -name '*.h' -a ! -name ${PREFIX}'*')
for i in ${FILES} ; do git mv $i $(dirname $i)/${PREFIX}_$(basename $i) ; done
sed -i 's/#include "\(.*\)\<\('$(python -c 'print "\|".join(f.split("/")[-1][:-2] for f in __import__("sys").argv[1:])' ${FILES})'\).h"/#include "\1'${PREFIX}_'\2.h"/' $(find -regex '.*\.\(h\|hpp\|c\|cpp\)')

cc @sg-, @bridadan, @kjbracey-arm, @mikaleppanen

@geky geky force-pushed the lwip-fix-header-file-collisions branch 2 times, most recently from 38b94ca to 39579c1 Compare February 23, 2017 20:51
Currently conflicts with standard header errno.h

PREFIX=lwip
FILES=$(find features/FEATURE_LWIP/lwip-interface/lwip/src/include -ty
pe f -a -name '*.h' -a ! -name ${PREFIX}'*')
for i in ${FILES} ; do git mv $i $(dirname $i)/${PREFIX}_$(basename $i
) ; done
sed -i 's/#include "\(.*${PREFIX}\/\)\('$(python -c 'print "\|".join(f
.split("/")[-1][:-2] for f in __import__("sys").argv[1:])' ${FILES})'\
).h"/#include "\1'${PREFIX}_'\2.h"/' $(find -regex '.*\.\(h\|hpp\|c\|c
pp\)')
@geky geky force-pushed the lwip-fix-header-file-collisions branch from 39579c1 to 4fcc2ca Compare February 23, 2017 21:10
@0xc0170
Copy link
Contributor

0xc0170 commented Feb 24, 2017

As far as I can tell the only solution is to rename the problematic file (lwip/errno.h). Let me know if anyone can think of another solution.

I can't and this is because of our include paths (all in) :-/ Howver, from the above, we would use I think whats called base path inclusion "lwip/errno.h". lwip do it, we don't do this (we might want to rethink this at least to avoid situations like this?).

Rename looks fine but we end up prefixing almost everything 😄

I wonder if suggestions from other projects how to include would not solve this? relative first (using base paths for istance), then system headers, would this break as well?

#include "lwip/errno.h"
#include <errno.h>

@mikaleppanen
Copy link

Previously we have renamed just the one header that collides. errno.h is used in lwip_err.c, sockets.h and under ppp directory if few modules which would need update. I would prefer that sort of correction also with this problem. Integrating new versions of lwip would demand less changes when only some of the modules needs update.

Also I am not seeing c module changes in this pull request?

@kjbracey
Copy link
Contributor

Presumably the colliding code is doing #include "errno.h" when they should be doing #include <errno.h>?

If so, changing that would solve it.

As far as I'm aware, standard C library headers are only guaranteed to be available with <>.

@kjbracey
Copy link
Contributor

I think the above should fix it, because it seems lwIP itself uses a mixture of #include "lwip/errno.h" and #include <errno.h>, and doesn't apparently have any problems.

But I don't actually see any includes of just "errno.h" in the tree. Can you point out where the problem actually arises? Is it an out-of-tree program including "errno.h"?

@kjbracey
Copy link
Contributor

Okay, I see the error from the logs. The IAR manual does seem to say that <> files are searched from -I include directories before the system directories.

Not very helpful behaviour, but technically allowable - the C99 spec does say behaviour is undefined if you have a file with any system header name in any of the "standard" search locations.

I'd be inclined to go with the limited patch of renaming that errno.h, as in PR#3762, and lwIP themselves should probably reconsider - even if all directories aren't on the search path, that directory might be on it as the current directory sometimes, so they'd potentially hit that rule inside the lwIP build regardless.

@0xc0170
Copy link
Contributor

0xc0170 commented Feb 24, 2017

I'd be inclined to go with the limited patch of renaming that errno.h, as in PR#3762, and lwIP themselves should probably reconsider - even if all directories aren't on the search path, that directory might be on it as the current directory sometimes, so they'd potentially hit that rule inside the lwIP build regardless.

Can you report it there please? Thanks for providing the useful info!

@geky Would you just rename that errno header file that conflicts?

@geky
Copy link
Contributor Author

geky commented Feb 24, 2017

Okay, I see the error from the logs. The IAR manual does seem to say that <> files are searched from -I include directories before the system directories.

Yep, and as far as I can tell the compiler does not support other include path options that would allow a workaround. 🙁

This issue showed up in #3762, in an effort to get it in #3762 changes lwip/errno.h -> lwip/lwip_errno.h. This pr is optional and just for naming consistency if you guys want it (I don't have a strong preference).

Otherwise we can just close this without concerns.

@kjbracey
Copy link
Contributor

I also see no IAR workaround. Okay, I vote for just having the #3762 fix. Reduced hassle of merging trumps consistency in this case, for me.

@0xc0170
Copy link
Contributor

0xc0170 commented Feb 27, 2017

Thanks for all the inputs and also for this patch. As we agreed, we close this one, we already renamed the conflicting header file referenced above.

@0xc0170 0xc0170 closed this Feb 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants