Author Topic: Need help: auto-complete can't find CreateFile  (Read 6462 times)

Offline jsandraw

  • Single posting newcomer
  • *
  • Posts: 3
Need help: auto-complete can't find CreateFile
« 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'?

Offline jsandraw

  • Single posting newcomer
  • *
  • Posts: 3
Re: Need help: auto-complete can't find CreateFile
« Reply #1 on: January 15, 2010, 02:24:41 pm »
Can't find CreateFile/CloseHandle, but auto-complete can find ReadFile/WriteFile, s.b. know why?

Offline Loaden

  • Lives here!
  • ****
  • Posts: 1014
Re: Need help: auto-complete can't find CreateFile
« Reply #2 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]

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6077
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Need help: auto-complete can't find CreateFile
« Reply #3 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;
}



If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9723
Re: Need help: auto-complete can't find CreateFile
« Reply #4 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).
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9723
Re: Need help: auto-complete can't find CreateFile
« Reply #5 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:
« Last Edit: January 15, 2010, 03:47:31 pm by MortenMacFly »
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6077
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Need help: auto-complete can't find CreateFile
« Reply #6 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), 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.
« Last Edit: January 15, 2010, 03:48:52 pm by ollydbg »
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline jsandraw

  • Single posting newcomer
  • *
  • Posts: 3
Re: Need help: auto-complete can't find CreateFile
« Reply #7 on: January 15, 2010, 04:28:46 pm »
Hey, this is my 4000th posting!!! :lol: :lol: :lol:

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