-
-
Notifications
You must be signed in to change notification settings - Fork 606
Working With Eclipse CDT
Install Eclipse, and its CDT (C Development Tooling), as is recommended on your distribution. E.g., on Fedora, "dnf install eclipse-cdt" is enough. If you prefer to install from source, check out the instructions in https://www.eclipse.org/cdt/.
Eclipse uses a Java virtual machine started with a fixed upper limit on its heap size, defined in /etc/eclipse.ini. The default limit is sometimes not large enough for indexing the OSv project. It's recommended to edit /etc/eclipse.ini (as root) and make sure the "-Xmx" setting is at least 1 GB.
Download OSv from git, and run "make". It is important to run "make" once before editing, because the first time we build OSv generates some header files which are needed for Eclipse to proper parsing of the other source files.
Under File -> New -> Project, select C/C++ folder and than select "Makefile Project with Existing Code". Click Next.
Give a project name and select the place where OSv code was downloaded, and select "Linux GCC" as the toolchain. You can now click Finish.
For eclipse to properly parse the OSv source files, it needs to be made aware of the appropriate header file directories (and their order) as we use in OSv's Makefile, and also about some predefined macros we use there.
In the past, Eclipse and Gcc did not default to C++11, so this had to be configured explicitly, but with Gcc 6 now defaulting to C++14, we no longer have to configure this explicitly.
The following instructions need to be updated... Some of it (like the C++11 configuration) is no longer necessary.
Project -> Properties -> C/C++ General -> Preprocessor Includes -> GNU C++ -> CDT User Setting Entries -> Add a "Preprocessor Macro"; Name: __GXX_EXPERIMENTAL_CXX0X__
value: 1
Project -> Properties -> C/C++ General -> Preprocessor Includes -> GNU C++ -> CDT User Setting Entries -> Add a “Include Directory”, in “Filesystem”, “/usr/include”
To use OSv provided libs and includes, and to work correctly with c++11, we need some more tweaks. So go to:
Project -> Properties -> C/C++ General -> Preprocessor Includes
Under Provides tab, select CDT GCC Built-in Compiler Settings and uncheck "Use global provider shared between projects". Use the following command:
${COMMAND} -E -P -v -dD "${INPUTS}" -std=c++11 -include /YOUR_PATH_TO_OSV_SOURCE/include/api/stdalign.h -nostdlib -nostdinc -nostdinc++
do not forget to replace YOUR_PATH_TO_OSV_SOURCE
This will prevent indexer to guess things in a wrong way:
Project -> Properties -> C/C++ General -> Indexer
Uncheck: "Index source files not included in the build" and "Allow heuristic resolution of includes'.
To make OSv's code formatter conform to OSv's coding style, go to Project -> Properties -> C/C++ General -> Formatter, Set "Enable project specific settings", choose the K&R formatter and then click on the "Edit..." button to edit the formatter, choose a new name (e.g., "OSV") and in the "Indentation" setting choose "spaces only" as a tab policy.