question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Generated includes file incorrectly prioritizes user headers over system version

See original GitHub issue

The TensorFlow Lite source tree contains a header file with the name “string.h”, inside the folder tensorflow/lite/. When compiling an mbed project with this nested file, any code that does #include <string.h> will import this version instead of the expected system header, causing mysterious compiler errors early in the process.

Other users have encountered the same problem: https://os.mbed.com/questions/85362/include-path-uses-incorrect-search

I thought I’d found a workaround by using .mbedignore to exclude the tensorflow folder and subdirectories, but while that gets around the earlier compilation errors, it has the unfortunate side effect of also not compiling the code in those folders.

After some digging, I found that the include paths were being set by a file like @./BUILD/DISCO_F746NG/GCC_ARM/.includes_18349b8ce7da3e19df69aba86e441bb6.txt. This contains a long list of -I directives, apparently for every subfolder in the workspace. There are a few problems with this:

  • Using -I means that every file is treated as a candidate for angle-bracket (system) includes. This is not what developers would normally expect for their own headers.
  • Recursively searching every subfolder is pretty surprising behavior too.
  • All of these directives override the default system headers, since they’re searched first.

I would love any suggestions on workarounds. Renaming the current offending string.h in our codebase might work in the short term, but it’s likely that other headers will hit similar issues in the future.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:1
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
0xc0170commented, Oct 19, 2022

@dardeshna if you use mbed tools (based on CMake), then this problem should not be there.

However, with mbed cli, the problem persists and it won’t be fixed as the tools were frozen long time ago (deprecated).

0reactions
dardeshnacommented, Oct 19, 2022

Is there a fix for this issue? I am having a similar problem with a header file in a third party library (ros_lib_kinetic) named time.h which is messing up the #include <time.h> directives within the mbed os source code.

Only the root folder of the ros_lib_kinetic library needs to be passed to the compiler via -I. All the internal #include directives within the library are namespaced properly with relative paths. Is there a way to disable this recursive behavior and manually set the directories passed with -I?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Compile errors for external headers - Visual Studio Feedback
The sample project includes a pair of header files that need to be moved to an external include folder (we use M:\Source\Include for...
Read more >
pkg-config files on >=10.14 assume headers in /usr/include
I tested only with libxml2 but I believe this issue affect all libs which have pkg-config file from Homebrew Library/Homebrew/os/mac/pkgconfig/ ...
Read more >
Why new Macs break your Docker build, and how to fix it
New Macs can break your Docker image build in unexpected ways; learn why, and how to fix it.
Read more >
Content-Disposition - HTTP - MDN Web Docs
In a regular HTTP response, the Content-Disposition response header is a header indicating if the content is expected to be displayed inline ...
Read more >
C/C++ include header file order - Stack Overflow
All headers (and indeed any source files) should include what they need. They should not rely on their users including things.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found