-
July 1st, 2013, 05:19 PM
#1
Windows 64 bit or 32 bit preprocessor directives
Hi,
I want to connect to an SQL Server database using ADO with VC++.
In order to do that you need to import an external dll, like so:
#import "C:\\Program Files (x86)\\Common Files\\System\\ado\\msado15.dll"
What if the OS is not 64 bit? That would mean the (x86)-suffix would be incorrect.
Does anyone know how to work around this using certain preprocessor directives?
Something like this, maybe?:
#if 64bit
#import "C:\\Program Files (x86)\\Common Files\\System\\ado\\msado15.dll"
#else
#import "C:\\Program Files\\Common Files\\System\\ado\\msado15.dll"
#endif
-
July 1st, 2013, 07:13 PM
#2
Re: Windows 64 bit or 32 bit preprocessor directives
Just remove the path and let the compiler find it on its own.
http://support.microsoft.com/kb/169496
gg
-
July 17th, 2013, 04:47 AM
#3
Re: Windows 64 bit or 32 bit preprocessor directives
#import <msado15.dll>
does not work and the following error is generated
'fatal error C1083: Cannot open type library file: 'msado15.dll': No such file or directory'
-
July 17th, 2013, 04:59 AM
#4
Re: Windows 64 bit or 32 bit preprocessor directives
Originally Posted by danielmofo
#import <msado15.dll>
does not work and the following error is generated
'fatal error C1083: Cannot open type library file: 'msado15.dll': No such file or directory'
Read about The #import Directive and how it searchs for type library files...
Victor Nijegorodov
-
July 17th, 2013, 05:04 AM
#5
Re: Windows 64 bit or 32 bit preprocessor directives
Ok, so do I need to add the following to Additional Include Directories to make it works for both 32 and 64 bit windows?
C:\Program Files (x86)\Common Files\System\ado
C:\Program Files\Common Files\System\ado
Will it also run on both 32 and 64 bit windows after compilation?
Last edited by danielmofo; July 17th, 2013 at 05:06 AM.
-
July 2nd, 2013, 02:46 AM
#6
Re: Windows 64 bit or 32 bit preprocessor directives
-
July 2nd, 2013, 06:44 AM
#7
Re: Windows 64 bit or 32 bit preprocessor directives
but in case you have an actual code path that depends on 64 vs 32bit...
_M_X64 is defined for 64bit builds
_M_IX86 is defined for 32bit builds (the actual value will depend on what processor you're targetting)
_WIN64 is defined for Win64 builds
_WIN32 is defined for Win32 builds
the above is for Visual C++. Other compiler will have different macro's.
-
July 2nd, 2013, 09:44 AM
#8
Re: Windows 64 bit or 32 bit preprocessor directives
>> the above is for Visual C++. Other compiler will have different macro's.
Indeed. Here is a good reference for several different compilers: http://sourceforge.net/p/predef/wiki/Home/
Those are generally for the target environment. There are no macro's for "what environment am I compiling on" in VC++, so it's best to let compiler options deal with import paths.
gg
-
July 18th, 2013, 02:51 AM
#9
Re: Windows 64 bit or 32 bit preprocessor directives
The #import directive will take care of the required headers (in fact it generates one, the .tlh), so you never need to add anything to Additional Include Directories.
Best regards,
Igor
-
July 18th, 2013, 05:50 AM
#10
Re: Windows 64 bit or 32 bit preprocessor directives
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|