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:
#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;
}
But when I have another try in C environment,everything is fine:
#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;
}
So what's wrong with what I have done?Help would be appreciated!
Regards,
Sam
Does sql.h and sqlext.h have extern "C" { } in them?
If not you should do:
extern "C"
{
#include " ... "
#include " ... "
}
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.
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:
extern "C"
{
#include " ... "
#include " ... "
}
Thank you so much.It works now.
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.