Code::Blocks Forums

User forums => General (but related to Code::Blocks) => Topic started by: Hendi48 on August 25, 2016, 07:06:14 pm

Title: Auto-completion compatible C standard library
Post by: Hendi48 on August 25, 2016, 07:06:14 pm
Hello,

I recently started using Code::Blocks 16.01 after my C project became too big to develop comfortably in Notepad++. One of the features that are really useful in NP++ is that it's aware of the C standard library and provides function prototypes with argument types and names when typing "memset(" etc.
Now, to get this type of behaviour in C::B, I figured I had to add the include folder to the compiler search path (I'm using GCC 6.1.0 from msys2/mingw). So far, so good. What it shows me now is this: "char* memset()". I guess it fails to properly parse the header, since it's written in a slightly convoluted way...
Code
_PTR	 _EXFUN(memmove,(_PTR, const _PTR, size_t));
_PTR _EXFUN(memset,(_PTR, int, size_t));
char *_EXFUN(strcat,(char *__restrict, const char *__restrict));
I also tried MSVC headers, but there it's even worse with 50 annotations for every function.

Is there any easy way to get IDE-friendly headers, preferably even with argument names?
Title: Re: Auto-completion compatible C standard library
Post by: ollydbg on September 04, 2016, 09:14:26 am
I think CC can handle such kinds of macros, if you search our forum by "_EXFUN", you will see some discussions. Such as: Is it possible for the parser to support newlib prototypes? (http://forums.codeblocks.org/index.php/topic,19278.msg131810.html#msg131810)
Title: Re: Auto-completion compatible C standard library
Post by: ollydbg on September 04, 2016, 09:50:08 am
Try to put those content in the main.c file of your project. (Note main.c is the only source file in your project).
Code
#define	_EXFUN(name, proto)		__cdecl name proto

FILE * _EXFUN(fopen, (const char *__restrict _name, const char *__restrict _type));

Now, after that, type "fopen", and see whether it will prompt the correct auto completion. It works fine here in my C::B.