Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: jsandraw on January 15, 2010, 01:53:58 pm

Title: Need help: auto-complete can't find CreateFile
Post by: jsandraw on January 15, 2010, 01:53:58 pm
when type createfile...., auto-complete just give 'CreateFileMoniker'

but CreateFile can compile and run in the .cpp

How can I set proper for auto-complete to show 'CreateFile'?
Title: Re: Need help: auto-complete can't find CreateFile
Post by: jsandraw on January 15, 2010, 02:24:41 pm
Can't find CreateFile/CloseHandle, but auto-complete can find ReadFile/WriteFile, s.b. know why?
Title: Re: Need help: auto-complete can't find CreateFile
Post by: Loaden on January 15, 2010, 02:29:06 pm
when type createfile...., auto-complete just give 'CreateFileMoniker'

but CreateFile can compile and run in the .cpp

How can I set proper for auto-complete to show 'CreateFile'?
I can confirm it. SVN6086


[attachment deleted by admin]
Title: Re: Need help: auto-complete can't find CreateFile
Post by: ollydbg on January 15, 2010, 03:32:41 pm
OK, I can confirm this.

This code does not work.
Code
#include <iostream>
#include <windows.h>
using namespace std;
int main()
{
    CreateFil
    return 0;
}

If you open the CC Debug dialog
see http://wiki.codeblocks.org/index.php?title=Code_Completion_Design#Code-Completion_debug_tool_dialog
, you will notice that "winbase.h" is not in the CC's file list, so this is the reason.

But this code works
Code
#include <iostream>
#include <windows.h>
#include <winbase.h>
using namespace std;
int main()
{
    CreateFi
    return 0;
}



Title: Re: Need help: auto-complete can't find CreateFile
Post by: MortenMacFly on January 15, 2010, 03:36:57 pm
windows.h should usually be enough. However, you find this section in windows.h:
Code
#ifdef RC_INVOKED
/* winresrc.h includes the necessary headers */
#include <winresrc.h>
#else

#include <stdarg.h>
#include <windef.h>
#include <wincon.h>
#include <winbase.h>
(...)
As CC does not fully support macro handling the first case (as if RC_INVOKED would be defined) is used. Thus the references are incomplete. However, I don't know "who" usually defines this macro. It looks like the resource compiler does so at runtime (compile time).
Title: Re: Need help: auto-complete can't find CreateFile
Post by: MortenMacFly on January 15, 2010, 03:41:03 pm
BTW:

Concerning macro handling: One thing that could "easily" be done is the following:

Similar like we cache the internal GCC dirs we could also cache the internal macros like this:
Code
gcc -E -dM a_dummy.c
...and similar for g++.

This could be tried to resolve when we come across a macro. We are able to identify the name of the macro already.

...just my 2 cent...

Edit: Hey, this is my 4000th posting!!! :lol: :lol: :lol:
Title: Re: Need help: auto-complete can't find CreateFile
Post by: ollydbg on January 15, 2010, 03:47:13 pm
BTW:

Concerning macro handling: One thing that could "easily" be done is the following:

Similar like we cache the internal GCC dirs we could also cache the internal macros like this:
Code
gcc -E -dM a_dummy.c
...and similar for g++.

This could be tried to resolve when we come across a macro. We are able to identify the name of the macro already.

...just my 2 cent...

Great Idea.
I have a discussion with NullWu( who supplied a script engine to handle macros, see Partial C/C++ preprocessor function for codecompletion (http://forums.codeblocks.org/index.php/topic,11377.msg77570.html#msg77570)), I think we can also consider it.
By the way, what does this sentence means "...just my 2 cent.."???
Also, I saw some blog about Visual C++ 10's intelligent sense. They can both handle the #if and # else statement.
Title: Re: Need help: auto-complete can't find CreateFile
Post by: jsandraw on January 15, 2010, 04:28:46 pm
Hey, this is my 4000th posting!!! :lol: :lol: :lol:

Congratulation, U're the Lucky-MAN. :-)