fopen deprecated warning

It looks like Microsoft has deprecated lots of calls which use buffers to improve code security. However, the solutions they’re providing aren’t portable. Anyway, if you aren’t interested in using the secure version of their calls (like fopen_s), you need to place a definition of _CRT_SECURE_NO_DEPRECATE before your included header files. For example: #define _CRT_SECURE_NO_DEPRECATE … Read more

Why does fatal error “LNK1104: cannot open file ‘C:\Program.obj'” occur when I compile a C++ project in Visual Studio?

This particular issue is caused by specifying a dependency to a lib file that had spaces in its path. The path needs to be surrounded by quotes for the project to compile correctly. On the Configuration Properties -> Linker -> Input tab of the project’s properties, there is an Additional Dependencies property. This issue was … Read more

MSVC doesn’t expand __VA_ARGS__ correctly

Edit: This issue might be resolved by using /Zc:preprocessor or /experimental:preprocessor option in recent MSVC. For the details, please see here. MSVC’s preprocessor seems to behave quite differently from the standard specification. Probably the following workaround will help: #define EXPAND( x ) x #define F(x, …) X = x and VA_ARGS = __VA_ARGS__ #define G(…) … Read more

fatal error LNK1112: module machine type ‘x64’ conflicts with target machine type ‘X86’

I wrote a blog entry about this, as I encountered this maddening problem, and finally yanked my system back into working order. These are the things to check, in this order: Check your properties options in your linker settings at: Properties > Configuration Properties > Linker > Advanced > Target Machine. Select MachineX64 if you … Read more

C++ Identify first number

this worked. kind of. My code is as follows: #include “stdafx.h” #include <iostream> using namespace std; int main () { int mnum [11]; int ctr; for (ctr=0; ctr<=10; ctr++) { cout << “Enter your mobile number: “; cin >> mnum [ctr]; } cout << “Your mobile number is “; if (mnum [3] == 1||2 && … Read more