question

OwenRansen-2591 avatar image
0 Votes"
OwenRansen-2591 asked OwenRansen-2591 answered

Including <afxdb.h> gives me a compile error

I'm trying to use the CDatabase class. I've done it in a different project fine, but in this one....

I've added <afxdb.h> to a project "stdafx.h" but I get a compile error:

7>c:\program files (x86)\windows kits\10\include\10.0.17763.0\um\sqltypes.h(123): error C2632: 'char' followed by 'char' is illegal


The offending line (in the sqltypes.h header)is this:

typedef unsigned char UCHAR;

Do I need to define something or do something or...


c++
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

SimpleSamples avatar image
0 Votes"
SimpleSamples answered

Is it possible that UCHAR is already defined? You can put the following in your stdafx.h just prior to the #include <afxdb.h>.

 #ifdef UCHAR
 #pragma message("defined")
 #else
 #pragma message("not defined")
 #endif

If that is not the cause then you probably need to provide more information about your project. Perhaps you can update your question and show what the contents of your stdafx.h is. Also, looking at the headers, the version of ODBC seems relevant so what version is it for your project?

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

OwenRansen-2591 avatar image
0 Votes"
OwenRansen-2591 answered

@SimpleSamples , the message I get is "defined". Your message prompted me to move the h to just before Windows.h in my stdfax.h:


 #include <afxdb.h>
 #include <Windows.h>


and now my project compiles. Many thanks!

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.