C++ ODBC problem with sqlucode.h header - visual-c++

I found a great C++/ODBC example here...
The project I downloaded builds great and everything works. However, when I copy the .cpp and .h files into another project, I seem to have a linking problem.
The SQLConnect function in sql.h is the one I want. When I right-click this function in the easyodbc.h file in the project I downloaded, it jumps to the declaration in sql.h. Life is good.
However, in the project I created, when I do this it jumps to a UNICODE definition in sqlucode.h. This seems to be causing problems and my test project crashes.
I don't have an #include for sqlucdode.h anywhere in my project, yet it still resolves the declaration to the one in sqlucode.h. How can I prevent this? Thanks.

Seems like you have a preprocessor problem rather than a linking problem.
You probably have a preprocessor definition for UNICODE (or _UNICODE) in your project file. In Visual C++ 2005 and 2008 you can fix this by going to your project properties and changing Character Set from Use Unicode Character Set to Use Multi-Byte Character Set. When you apply this setting, Visual Studio fixes up the right preprocessor and linker settings for you.
If you have an earlier version of Visual Studio you can still fix it by changing the preprocessor definitions for UNICODE and _UNICODE to _MBCS - it's just you'll have to find them yourself.
EDIT: I just downloaded that example code and tried it - good news, it's exactly as I guessed, change to a multibyte character set and you'll be fine.

Related

Visual studio code Linux - Squiggle lines don't show up on .h files, but work well on .cpp files

I noticed that somehow VS Code C/C++ Intellisense is not working on .h files. But they work pretty well on .cpp files.
I tried all the header files are not showing any errors, and it starts to be really furstrating, because it doesn't show if I mistype something.
I have installed the C/C++ extension by Microsoft.
Why is this happening?
I checked the settings but didn't find any good solutions there.

Extend Visual Studio functionality for Installshield ISPROJ Project type

InstallShield must be the crappiest "industry standard" application in existence, for reasons too numerous to enumerate here. However, one of those deficiencies is something I'd like to be able to fix, and with my first foray into writing an extension for Visual Studio (currently using 2015 version).
InstallShield has created a .isproj type, to allow integration with Visual Studio. This allows a developer to create an installer that references the output of a project as the files to include in the installer (rather than having to manually select individual files to include). This works well enough as long as the .isproj is being built in Visual Studio, and in a solution that references the project for which you need the output.
However, I also have an automated build for my installer projects, that we run on a build server using MSBuild. When attempting to build this way, we were getting completely opaque error messages indicating that the project output references above couldn't be resolved.
As with all InstallShield errors, Googling for answers turned up nothing except for multitudes of other people having the same problem. So I decided to dig into the plain text of the .isproj to see what I could find.
As it turns out, the .isproj type is a just a regular MSBuild script, and it even has lines commented out that explain options that can be added to the project; one of those things that can be added is an ItemGroup containing ProjectReference nodes. Manually adding the nodes helped solve the problem. Command-line build now works.
However, I am dissatisfied with a) having to manually type this stuff in, b) having no visual representation of what projects are being referenced, and c) not finding out about a problem until the build fails. So, I would like to be able to extend Visual Studio to help me with this. Here's what I'd like to do:
1) Add a "References" node to the project in Solution Explorer that acts like the References node for any normal .csproj.
2) Restrict the available References to other projects in the the current solution.
3) Visually represent a project with missing references (e.g. by underlining the project name with a colored squiggly, as with errors/warnings), and potentially failing the build if missing (depending on whether I want to treat it as an error or a warning; TBD).
To these ends, I've downloaded MPF for Projects - Visual Studio 2013, which provides an SDK for creating a new project type.
However, before digging too deeply, I need to know if it's even possible to EXTEND an existing project type, as described above, as I obviously don't have InstallShield source code. Also, any links or guidance as to a starting point for doing so would be greatly appreciated.

Cannot open include file 'rpcerr.h': No such file or directory

I was happily compiling and running source code today. Then I added a few lines to one of my modules, and suddenly Visual Studio 2012 refused to compile the code, with the error message:
error C1083: Cannot open include file: 'rpcerr.h': No such file or directory.
I'm not sure why the compiler suddenly needs to find rpcerr.h. I'm not doing anything I wasn't doing yesterday, but now I can't make the error go away.
I also have not been able to find rpcerr.h, myself. The reference is in rpc.h, which is part of the Visual Studio library. I'm guessing it got linked in because I included <windows.h>. But I don't know where I can find rpcerr.h, or what this file is supposed to do.
I would really like to go forward with this development. I'm guessing the code tried to compile rpcerr.h for a good reason, and that if I'm going to be using rpc.h for whatever reason this gets compiled into my source code, then I should get rpcerr.h as well. But trying to find it is sending me into a mobius loop.
Currently, the compiler is only complaining about rpcerr.h.
I'd better write this up, this is bound to happen again sooner or later. The <rpc.h> SDK file is stone cold old and dates back to the days that Microsoft supported writing code for an Apple Macintosh. It still supports it, there's an #include for rpcerr.h. But that file is no longer supplied, only rpcnterr.h is available.
You need to scan your source, or recently added #includes, for the a #define for MAC or _MAC, the one that Microsoft uses to select a Macintosh target. Using the editor's "Go To Definition" context menu command is the easiest way.
Or use this as a workaround:
#undef MAC
#undef _MAC
#include <rpc.h>
Or change the order of #includes. Beware that these workarounds might have side-effects, depending on how the other definition is used.

Loading Boost 1.40.0 into Intellisense in Visual Studio 2005?

Is there any way to get Intellisense in Visual C++ for Visual Studio 2005?
I'm trying to get the Boost libraries to load up with intellisense and in the object browser/class view.
I installed the binary for Windows with the BoostPro installer (BoostPro 1.40.0 Installer).
I'm not certain that it comes with the source code however, which may be required to make Intellisense work in VS2005.
Boost is open source, and mostly header only. Just make sure IntelliSense knows the directory where boost resides so it can explore it.
As an un-answer, you might try out Visual Assist X, which works far better and has more features that Visual Studio's IS.
To make sure Intellisense can find boost, just make sure Boost is in the include directories (under Project Properties->C/C++->Additional Include Directories). Maybe move it to the top. After that, close your instance of Visual Studio, and search the a *.ncb file near your project, and delete it. This will cause IntelliSense to refresh. This should hopefully be enough for it to assist you. (You have to include boost headers into your source files with #include for IntelliSense to consider it)
Keep in mind boost has some very complex parts that IS will choke on, but should still provide the names.
Intellisense scans the headers #included in source files in Visual C++ projects.
So create a project with a single source file that includes the top level header of the boost library that you're interested in. Some of the boost code can't be parsed by intellisense though, and the boost code contains a lot of code to workaround language or compiler limitations that's just noise to someone wanting to see the user facing structure of the libraries.

Strange Dependency Behavior in VS.NET 2005 (Unnecessary .CPP Compilation)

I work on a large Visual C++ (MFC) project in VS.NET 2005.
I have noticed strange behavior in Visual C++ 2005. Often, I will change one line of code in a .CPP file but many .CPP files will compile as a result of this. I have never seen this until VS.NET 2005. Theortically, changing a line of code in a .CPP file should simply require recompilation of that .CPP file and re-linking of the PE file.
What am I not understanding about the build process.
I found this link helpful when solving a similar problem, was under pressure at the time, I tried a few things and the issue went away, for the life of me I don't know (or can't remember) which - if any - helped.
Hope this helps
This is a strange bug in the VS2005 dependency behavior. To find out one suggestion would be to take the following steps:
Go to Tools -> Options ->
Projects and Solutions -> Build and
Run -> MSBuild Project Build output
Verbosity and select Detailed
Compile your project.
This will give you a detailed output of the build which "may" help you arrive at a solution to your problem.

Resources