Cuda eclipse and time.h, Symbol 'CLOCK_PROCESS_CPUTIME_ID' could not be resolved although program runs - eclipse

I admit, this is not really a problem, but more an annoying thing: basically in the Eclipse editor, installed by the Cuda toolkit, I am using this function:
/* Get current value of clock CLOCK_ID and store it in TP. */
extern int clock_gettime (clockid_t __clock_id, struct timespec *__tp) __THROW;
as the following:
clock_gettime((clockid_t)CLOCK_PROCESS_CPUTIME_ID, &time1);
The "problem" is that CLOCK_PROCESS_CPUTIME_ID is not resolved, and then the whole project appears as containing some error, but if I compile and run, no problem at all
I have included this
#include <time.h>
#include <iostream>
I included also the rt library. How do I make the error go away?

You need to add your includes to your project's preferences:
Right click on your project, choose General/Paths and Symbols. There, you can add your custom include directories that will be browsed by Nsight for symbols.

Related

creating a define only used by eclipse

I have project that was created in another IDE that is build for a specific microcontroler. In the code faris used quite often and it is comprehended by the IDE and compiler.
I would like to use eclipse to edit the code, because it is more convinient to use. But it generates a lot of warnings and errors in the editor because he can not resolve the far.
I could create a macro #define far, but I would have to remove it when I want to compile the code. I don't compile with eclipse, because getting the compiler to work there is cumbersome and might introduce problems.
So is there a possibility that eclipse itself can handle the far for its syntax check?
Another approach that involves modifying your code rather than the project settings would be:
#ifdef __CDT_PARSER__
#define far
#endif
__CDT_PARSER__ is a macro that is automatically defined by CDT's parser when it processes your code, but not by any compiler.
After I searched a bit more I found an answer here:
https://www.eclipse.org/forums/index.php/t/72375/
Go to the menu:
Project -> Properties -> C/C++ General -> Path and Symbols ->
Symbols
and add a Symbol called far with the value /* */.
I just left the value empty and it worked.

Error while using custom library "undefined reference" [AVR]

I am using Eclipse in order to program a PID line follower robot. The microcontroller used is an Atmega328P. For that, I am using one QTR-8RC IR sensor, by Pololu and two modified servos for continuous rotation. I and my partner decided to use the Pololu AVR library since it contains functions specifically for servo control and for the IR sensor.
The problem is Eclipse does recognize the library but it does not compile.
Eg:
#include <pololu/orangutan.h>
#include <pololu/3pi.h>
#include <pololu/qtr.h>
#include <pololu/encoders.h>
unsigned char qtr_rc_pins[]={IO_D2,IO_D3,IO_D4,IO_D5,IO_D6,IO_D7}; //Setup Qtr pins
void main(){
qtr_rc_init(qtr_rc_pins,6,2000,255); //starts qtr
while(1){} //does nothing
Whenever I try to compile this eclipse gives me the following error:
undefined reference to `qtr_rc_init'
More information on the Pololu AVR library.
The undefined reference error you are getting can be solved by adding -lpololu_atmega328p to your linker flags. For more information about what compiler and linker options you need, see the "Using the Pololu AVR Library for your own projects" section in the user's guide you linked to.

stm32f469 FreeRTOS+STemWin with CubeMX and keil: Bad operand types (UnDefOT, Constant) for operator (*

I'm making project generated with STM32CubeMX for stm32f469i-disco.
I have based setup on "FreeRTOSconfig.h" from "Demonstration" project in STM32CubeFWF4V1.16.0 repo. Fresh project from CubeMX compiles without problems, but after adding STemWin lib "STemWin532_CM4_OS_Keil_ot.lib" I get the error
"..........\Middlewares\ThirdParty\FreeRTOS\Source\portable\RVDS\ARMCM4F\port.c(507):
error: A1586E: Bad operand types (UnDefOT, Constant) for operator ("
Interesting fact is that "Demonstration" compiles without this error.
How do I get the project configured:
In CubeMX:
Add periphs needed: DMA2D, DSIHost, FMC etc.
Add BSP drivers for touchscreen etc.
Now, it copiles without problems.
Clone "Clock Configuration" based on "Demonstations"
In "Configuration" tab I clone all configuration based on code from "Demonstrations"
Then in Keil:
5. I update Include Path in target options.
Add all STemWin files and when i try to compile:
"...Bad operand types..."
When I disable freertos in CubeMX and add non-OS STemWin lib it compiles without problems.
When I try to compile non_OS STemWin lib with FreeRTOS enabled, it fails with the same message.
What have I tried to do?
Update port.c. Nothing changed.
Am I missing something while creating project?
After spending 2 days to find out what might be the reason for this error, I just found it and my project now compiles with FreeRTOS enabled and all the other sources used initially. Well, it's apparently a recursive include for stm32f4xx_hal.h file. I have added some modules from the demo package and those have some dependencies. Because I wanted to strip out some functions from some modules, I have manually added the includes/resources for the functions needed, which has contributed to that error, as I did not add any guards to my includes.
The offending line was in port.c file, and the error was because of a wrong constant value passed to the assembly line 483: mov r0, #configMAX_SYSCALL_INTERRUPT_PRIORITY
Replacing configMAX_SYSCALL_INTERRUPT_PRIORITY with any numeric value has helped in compiling the code, but I thought I should not leave it like that and it would be much better if I found out the reason for the problem.
More could be found here:
https://community.st.com/thread/44751-portc483-error-a1586e-bad-operand-types-undefot-constant-for-operator
I got a same problem while building a Nucleo-F401RE board firmware with CubeMX 4.25.
This problem started just after setting LL driver use (Low-Level driver) instead of HAL in a CubeMX setting dialog.
I think this problem is from complicit in C definition of header file.
Including LL driver header may change __NVIC_PRIO_BITS definition in somewhere.
#ifdef __NVIC_PRIO_BITS
#define configPRIO_BITS __NVIC_PRIO_BITS
#else
#define configPRIO_BITS 4
#endif
#define configMAX_SYSCALL_INTERRUPT_PRIORITY (configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS))
Changing __NVIC_PRIO_BITS to 4 in a generated source code will solve the problem.
/* mov r0, #configMAX_SYSCALL_INTERRUPT_PRIORITY */
mov r0, #(configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - 4))

How to set Eclipse CDT to index / resolve std files

I have the following piece of code:
#include <iostream>
using namespace std;
int main()
{
vector<int> v; //Symbol vector could not be resolved
return 0;
}
The IDE complains about "vector": Symbol vector could not be resolved.
If I right click the "vector" keyword -> Source -> Add Include, nothing happens.
If I manually add #include <vector>, then everything is just fine, the file is indexed and I can use its member functions.
However, I expect the IDE to generate these include files for me, instead of manually adding them. How to setup eclipse to work like this?
I am using Ubuntu 16.04 and Eclipse CDT Neon.
This will only work if another file in your project already includes <vector>.
The way Add Include works is it searches the project's index for the name it's invoked on. If it finds a binding (function, type, etc.) corresponding to that name in the index, it sees what file declares that binding, and then includes that file for you.
For this to work, the binding corresponding to the name must be in the index already. For bindings declared in files external to your project (such as standard library headers), that will only be the case if the external file is already included by some file in your project.
#HighCommander4 - I noticed, through practice, the indexer behaves like in your description. There must be another file which already includes vector in order to have it in the index.
Given this behavior we can do the following:
One workaround is to have a dummy cpp file including <bits/stdc++.h>. Most of the stl headers are there. The header is available for GCC. For MSVC we can simply copy the content of into this dummy cpp file.
Another workaround is to add a linked folder to the location of the stl, in my case this is /usr/include/c++/5. In this case the whole stl library gets indexed from the very beginning.

Eclipse signals an error but the code compiles

I'm writing some C++ code with eclipe.
I have a strange behavior with vector objects.
When I use the method resize for example, Eclipse returns the following error:
#include "vector"
...
vector<int> a;
a.resize(5);
Error: Invalid arguments candidates are: void resize(?, int).
However the code compiles from command line.
How can I fix this fastidious behavior of eclipse?
After quite a while searching and tinkering with settings, I think I have found an answer. To get the indexer parsing the code correctly I had to:
Right click the project -> Properties
Go to C/C++ General -> Preprocessor Include Paths, Macros etc.
Click the providers tab
Check the CDT GCC Build-in Compiler Settings option
Apply
Rebuild index