Makefile project configuration [message #1828232] |
Thu, 04 June 2020 14:20 |
Karolis Milieška Messages: 4 Registered: June 2020 |
Junior Member |
|
|
Hello,
My use case includes using Eclipse CDT basically as a very fancy text editor with superb indexer.
I have mixed C and C++ Makefile Corss ARM GCC project. I am not using Eclipse's builder, only invoking make.
Please help me configure my workspace. I have read a lot of resources online already.
I have:
1) created "Makefile Project with Existing source" (problem described below also applies to C or C++ projects as well)
2) enabled "CDT Cross GCC Built-in Compiler Settings" provider with following invoke command:
C:\_env\gcc\9-2019-q4-major\bin\arm-none-eabi-g++.exe ${FLAGS} -E -P -v -dD "${INPUTS}"
and it works by filling up settings entries.
The problem is that since it is g++, it adds same entries for both GNU C and GNU C++ languages (.c and .cpp files). That results in C sources having C++ defines (like __cplusplus), which breaks indexer itself.
Also, I once had header file, which had "Syntax error" on extern "C" linkage specification under #ifdef __cplusplus. It was only included in few C source files. When it got included into C++ source file, syntax errors where gone. Note that it is only Eclipse related, it was building successfully before and after.
How should I configure Eclipse properly, to be able to work with mixed C/C++ projects?
|
|
|
Re: Makefile project configuration [message #1828250 is a reply to message #1828232] |
Thu, 04 June 2020 23:32 |
David Vavra Messages: 1426 Registered: October 2012 |
Senior Member |
|
|
Use gcc and a file with either a .c or .cpp extension.
GCC selects the proper compiler based upon the extension.
So for C builtins: gcc -E -P -v -dD no.c
For C++ builtins: gcc -E -P -v -dD no.cpp
no.c and no.cpp are empty files.
You can override it with the -x flag.
https://gcc.gnu.org/onlinedocs/gcc/Overall-Options.html#Overall-Options
You can only pick languages that gcc has been configured with.
That said, CDT uses files with .c and .C and changes the compiler.
You can view this by allocating a console (checkbox in provider tab).
gcc -E -P -v -dD <workspace>/.metadata/.plugins/org.eclipse.cdt.managedbuilder.core/spec.c
g++ -std=c++17 -E -P -v -dD <workspace>/.metadata/.plugins/org.eclipse.cdt.managedbuilder.core/spec.C
but this is in a project that has both C and C++ natures.
Don't know what would happen if one of them is missing.
Or if a cross compiler prefix is being used.
[Updated on: Fri, 05 June 2020 07:45] Report message to a moderator
|
|
|
|
Re: Makefile project configuration [message #1828271 is a reply to message #1828264] |
Fri, 05 June 2020 10:48 |
David Vavra Messages: 1426 Registered: October 2012 |
Senior Member |
|
|
Quote:Provider is only one command. You say that output is parsed for multiple languages?
Yes.
Two separate executions of the provider command with different files.
One for C and one for C++.
If the command uses ${COMMAND} the proper compiler will also be used as determined by the selected toolchain.
It's the one place outside of a Managed Build that uses the toolchain.
[Updated on: Fri, 05 June 2020 10:53] Report message to a moderator
|
|
|
|
|
Re: Makefile project configuration [message #1828283 is a reply to message #1828280] |
Fri, 05 June 2020 15:06 |
David Vavra Messages: 1426 Registered: October 2012 |
Senior Member |
|
|
Quote:Is it legit a way to not use MBS at all and only configure "C/C++ General -> Preprocessor Include Paths, Macros etc."? What other side effects it may have?
The Managed Build (assuming that's what you mean by MBS) is really to generate makefiles. The builtin provider borrows from it's toolchain but can be bypassed.
Quote:Is it possible to configure ${COMMAND} without setting a toolchain or other MBS settings?
I've never tried but suspect you can't. It seems to be dynamic.
---
I'm not quite sure what you are getting at with (3).
The Indexer isn't a compiler although it seems to act like one.
It remembers only the last definition of symbols it encounters.
Doing otherwise defeats the purpose of having an Indexer which is to quickly find things.
If you have multiple definitions that are arbitrarily selected for configuration purposes
then you might want to look into having separate projects with one for each configuration.
|
|
|
Powered by
FUDForum. Page generated in 0.25285 seconds