I setup Eclipse C++ - Version: Neon Release (4.6.0) - Build id: 20160613-1800 - with the GNU gcc ARM Embedded Toolchain (not gcc4mbed). The toolchain works great, but I ran into an issue involving (I think) Eclipse's indexer on my latest project.
My problem should be clear if I give the steps to reproduce my issue:
Create some class and #include "mbed.h"
Declare some member variable of type DigitalOut. Notice that Eclipse recognizes this just fine because the text turns bold, and code completion works fine when interacting with the variable.
Declare another member variable of type PwmOut. Notice that Eclipse does NOT recognize this, the text does not turn bold, and code completion doesn't work because Eclipse doesn't know what a PwmOut is. Eclipse says:
Errors (1 item)
Type 'PwmOut' could not be resolved. - main.cpp - Semantic Error
How is it possible that Eclipse can recognize DigitalOut but not PwmOut? Both are listed in the same code block inside mbed.h--and DigitalOut.h is in the same directory as PwmOut.h.
If it helps, here is an example project I exported from developer.mbed.org that you can import into Eclipse C++ as an existing Makefile project.
I have tried adapting suggestions I found such as adding the directory with these headers in Project->Properties->C/C++ General->Paths and Symbols->Includes, rebuilding the index, and "Freshening" all files in the index. I just can't get Eclipse to recognize them.
EDIT: I'd like to add that if I click on the "Type 'PwmOut' could not be resolved" error message in the "Problems" window, Eclipse locks up for a few seconds, then crashes with a stack overflow.
I am sorry to say that my solution probably isn't very generalizable or helpful to other people's Eclipse C++ issues.
In your developer.mbed.org exported project folder, find the file "device.h" located in the mbed subdirectory at
./mbed/TARGET_LPC1768/TARGET_NXP/TARGET_LPC176X/TARGET_MBED_LPC1768/device.h
Mine was more or less empty.
Notice this device.h has a bit more detail in it.
When you export a project from developer.mbed.org, it gives you a zip with all your sources, as well as an "./mbed" directory that contains the header files and objects for the specific microcontroller with which you're working.
Most of NXP/ARM's controllers should have some variation of a DigitalOut or DigitalIn class, since that kind of functionality is very basic and common to a controller. However, this particular chip (the LPC1768) has an independent module onboard to handle pulse width modulation. This module might not be found on all of NXP/ARM's chips, so you can think of this as a special case we need to take care of when setting up a workspace environment in an IDE such as Eclipse.
Particularly, the mbed exported project contains a header located (for me) at
./mbed/TARGET_LPC1768/TARGET_NXP/TARGET_LPC176X/TARGET_MBED_LPC1768/device.h
This device header should define preprocessor directives specific to the device you're programming. Mine was empty, but the one at the official repo for the LPC1768 has a lot of #defines in it for this controller. As long as the DEVICE_PWMOUT directive in device.h is defined to be equal to 1 (and it is), Eclipse will know that it is supposed to recognize the PwmOut class.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.