User forums > Using Code::Blocks
How to use sql*.h in C++ in mingw in C::B under WinXP?
(1/1)
samsam598:
When I tried to use sql.h sqlext.h etc reside in mingw\include,I found it is not a simple task in C++ environment.So many thing the compiler can not found:va_list,SQLHANDLE,SQLHDESC...
I was just creating a new project by new->console app->c++,using mingw.Below is the code:
--- Code: ---#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <windef.h>
#include <winbase.h>
#include <windows.h>
#include <windowsx.h>
#include <sqltypes.h>
#include <sqlucode.h>
#include <sql.h>
#include <sqlext.h>
#include <iostream>
using namespace std;
int main()
{
cout << "Hello world!" << endl;
return 0;
}
--- End code ---
But when I have another try in C environment,everything is fine:
--- Code: ---
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <windows.h>
#include <sql.h>
#include <sqlext.h>
int main()
{
printf("Hello world!\n");
return 0;
}
--- End code ---
So what's wrong with what I have done?Help would be appreciated!
Regards,
Sam
oBFusCATed:
Does sql.h and sqlext.h have extern "C" { } in them?
If not you should do:
--- Code: ---extern "C"
{
#include " ... "
#include " ... "
}
--- End code ---
zabzonk:
I use th Windows SQL headers in C++ code all the time, with absolutely no problems. One thing I would observe is that your includes are different in the two samples - make them the same (apart from any C++ headers).
Also, this is not a Code::Blocks issue, so your question will probably shortly be locked. I suggest asking it somewhere like StackOverflow.
samsam598:
--- Quote from: oBFusCATed on December 15, 2009, 09:43:19 am ---Does sql.h and sqlext.h have extern "C" { } in them?
If not you should do:
--- Code: ---extern "C"
{
#include " ... "
#include " ... "
}
--- End code ---
--- End quote ---
Thank you so much.It works now.
zabzonk:
Using the extern "C" should not be necessary, as the headers already do this for you. I think you have some other underlying problem in the way you are building your app.
Navigation
[0] Message Index
Go to full version