Eclipse giving me Invalid arguments ' Candidates are: void * memset(void *, int, ?) ' though I know the args are good

djc6535 picture djc6535 · Oct 23, 2012 · Viewed 34.8k times · Source

I am getting an invalid arguments error in eclipse, though I am confident my arguments are good. The suggested arguments contains a '?' which I think may indicate the problem, though I do not know how to fix it.

I have done my best to copy the example I saw here:
http://www.cplusplus.com/reference/clibrary/cstring/memset/

In order to be certain that I am getting the args right.

#include <stdio.h>
#include <string.h>
void foo()
{
    char str[] = "why oh why does my IDE give me errors when I know my args are good?";
    memset(str, '-', 4);
    puts(str);
}

Eclipse gives me the following error on the memset line:

Invalid arguments ' Candidates are: void * memset(void *, int, ?) '

What could be causing this? And what is up with that '?' as the 3rd arg?

Thanks in advance!

PS: Just noticed I am getting similar errors when I try to use operations like malloc, calloc, etc.

Answer

Catskul picture Catskul · Jun 18, 2014

In Eclipse:

  • right click the project
  • click properties
  • Expand "C/C++ general" the item in the left hand tree view by clicking the arrow, (just clicking the item itself does not expand the suboptions)
  • From the suboptions select "Preprocessor Include Paths, Macros etc."
  • Click the "Providers" tab
  • Check the box next to "CDT GCC Built-in Compiler Settings [ Shared ]".

Edit:

The reason this works is that there are a bunch of default includes and defines that the compiler silently adds behind the scene when you compile. These instructions get eclipse to grab these otherwise silent preprocessor directives so that it's own indexer is using the same settings