use macro token in pragma result in incorrect substitution - c++

I'm trying to use macro with "pragma include_alias" in VS2010, but I got a odd compiling warning which means the substitution is incorrect.
Here is the code:
18 #define RAPID_INCLUDES_PATH(MY_TARGET_HEADERS) "C:\\thirdpart\\rapidxml-1.13\\" ## #MY_TARGET_HEADERS
19 #define TEST(empty) "C:\\thirdpart\\rapidxml-1.13\\rapidxml_print.hpp"
//WORKS
21 #pragma include_alias( "rapidxml.hpp", "C:\\thirdpart\\rapidxml-1.13\\rapidxml.hpp" )
22 #pragma include_alias( "rapidxml_print.hpp" , TEST(empty) )
//FAILS
23 #pragma include_alias( "rapidxml_utils.hpp" , RAPID_INCLUDES_PATH(rapidxml_utils.hpp) )
24 #pragma include_alias( "rapidxml_iterators.hpp" , RAPID_INCLUDES_PATH(rapidxml_iterators.hpp) )
26 #include "rapidxml.hpp"
27 #include "rapidxml_iterators.hpp"
28 #include "rapidxml_print.hpp"
29 #include "rapidxml_utils.hpp"
The error messages:
1> Touching "Debug\xml2.unsuccessfulbuild".
1>ClCompile:
1> stdafx.cpp
1>d:\workspace\v10\xml2\xml2\stdafx.h(23): warning C4081: expected ')'; found 'string'
1>d:\workspace\v10\xml2\xml2\stdafx.h(24): warning C4081: expected ')'; found 'string'
1>d:\workspace\v10\xml2\xml2\stdafx.h(27): fatal error C1083: Cannot open include file: 'rapidxml_iterators.hpp': No such file or directory
1>
1>Build FAILED.
1>
It seems there're some misuses of macro.
Anyone knows how to fix it? Thanks a lots.

Related

PerforceChangeList : error : No matching clients for root

I am syncing and building a project using jenkins with msbuild tool, but I keep getting this error everytime I run the build, either in VS or through Jenkins. I honestly have no idea what it means and I have not found any information on internet. I have another very similar project which runs fine. Any help or what to start checking it would be much appreciated as I have delete and set the job from scratch with the same result. This is the output I get from jenkins:
"C:\Users\User\.jenkins\workspace\Age_3_DE\Source\Age3DE.sln" (default target) (1) ->
"C:\Users\User\.jenkins\workspace\Age_3_DE\Source\age3\age3.vcxproj" (default target) (2) ->
(PreBuildEvent target) ->
PerforceChangeList : error : No matching clients for root=C:\Users\User\.jenkins\workspace\Age_3_DE\ [C:\Users\User\.jenkins\workspace\Age_3_DE\Source\age3\age3.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets(128,5): error MSB3073: The command "C:\Users\User\.jenkins\workspace\Age_3_DE\Source\..\Scripts\PerforceChangeList.bat age3 "C:\Users\User\.jenkins\workspace\Age_3_DE\Source\age3\PerforceVersion.inc" "C:\Users\User\.jenkins\workspace\Age_3_DE\Source\age3\resource_version.h" [C:\Users\User\.jenkins\workspace\Age_3_DE\Source\age3\age3.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets(128,5): error MSB3073: :VCEnd" exited with code -1. [C:\Users\User\.jenkins\workspace\Age_3_DE\Source\age3\age3.vcxproj]
27 Warning(s)
2 Error(s)
resource_version.h file:
#pragma once
#define VERSION_MAJOR 100
#define VERSION_MINOR 10
#define VERSION_BUILD 0
#define VERSION_STRING "100.10.0.0"
and PerforceVersion.inc:
#pragma once
namespace PerforceInfo {
const char* gChangeList = "00000";
const char* gVersionString = "100.10.0.0";
const char* gUserName = "";
const char* gClientName = "";
const char* gClientHost = "";
const char* gClientRoot = "";
const char* gClientStream = "";
}
Here is an image with the exactly error and the line where the error happens from VS Error

C/C++ - working with interrupts in visual studio c++

I am a computer science student and recently learned how to use interrupts in C.
after a couple of search in web I came up with this code:
#include <stdio.h>
#include <dos.h>
#include <conio.h>
#ifdef __cplusplus
#define __CPPARGS ...
#else
#define __CPPARGS
#endif
#define INTR 0x1c
#define gotoxy(x,y) printf("\033[%d;%dH", (x), (y))
//#define clear() printf("\033[H\033[J");
/*
//positioning
void gotoxy(int x, int y)
{
printf("%c[%d;%df",0x1B,y,x);
}
*/
void interrupt handler(__CPPARGS);
void interrupt ( *oldhandler)(__CPPARGS);
int countS = 0;
int s = 0;
int m = 0;
int ms = 0;
int l = 0;
int flag = 0;
int main(void)
{
clrscr();
printf("%02d:%02d:%02d",m,s,ms);
oldhandler = getvect(INTR);
setvect(INTR, handler);
char c;
while(1)
{
c = getch();
switch(c){
case 'e':
goto exit_loop;
break;
case ' ':
flag = 1-flag;
break;
case 'r':
flag = s = m = ms = l = 0;
clrscr();
printf("%02d:%02d:%02d",m,s,ms);
break;
case 'l':
gotoxy(++l,0);
printf("%02d:%02d:%02d",m,s,ms);
break;
}
}
exit_loop:;
setvect(INTR, oldhandler);
return 0;
}
void interrupt handler(__CPPARGS)
{
if(flag == 1){
countS++;
ms += 55;
if(countS == 18)
{
countS = ms = 0;
s++;
if(s==60)
{
m++;
s = 0;
}
}
gotoxy(0,0);
printf("%02d:%02d:%02d",m,s,ms);
}
}
this code is some kind of stopwatch in C console application and its work perfect in historical Turbo C++.
I changed my IDE and now using Visual studio 2013, when i create a new project in Visual C++->win32ConsoleApplication and paste this code in the main file. its not work. then an error says that i should add #include "stdafx.h" in the first of my file. after doing so, this is my main error list:
Error 1 error C2146: syntax error : missing ';' before identifier 'handler' c:\users\mohammad\documents\visual studio 2013\projects\consoleapplication1\consoleapplication1\consoleapplication1.cpp 32 1 ConsoleApplication1
Error 2 error C2182: 'interrupt' : illegal use of type 'void' c:\users\mohammad\documents\visual studio 2013\projects\consoleapplication1\consoleapplication1\consoleapplication1.cpp 32 1 ConsoleApplication1
Error 3 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\users\mohammad\documents\visual studio 2013\projects\consoleapplication1\consoleapplication1\consoleapplication1.cpp 32 1 ConsoleApplication1
Error 4 error C2065: 'oldhandler' : undeclared identifier c:\users\mohammad\documents\visual studio 2013\projects\consoleapplication1\consoleapplication1\consoleapplication1.cpp 33 1 ConsoleApplication1
Error 5 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\users\mohammad\documents\visual studio 2013\projects\consoleapplication1\consoleapplication1\consoleapplication1.cpp 33 1 ConsoleApplication1
Error 6 error C2086: 'int interrupt' : redefinition c:\users\mohammad\documents\visual studio 2013\projects\consoleapplication1\consoleapplication1\consoleapplication1.cpp 33 1 ConsoleApplication1
Error 7 error C2143: syntax error : missing ';' before '(' c:\users\mohammad\documents\visual studio 2013\projects\consoleapplication1\consoleapplication1\consoleapplication1.cpp 33 1 ConsoleApplication1
Error 8 error C2059: syntax error : ')' c:\users\mohammad\documents\visual studio 2013\projects\consoleapplication1\consoleapplication1\consoleapplication1.cpp 33 1 ConsoleApplication1
Error 9 error C2059: syntax error : ';' c:\users\mohammad\documents\visual studio 2013\projects\consoleapplication1\consoleapplication1\consoleapplication1.cpp 33 1 ConsoleApplication1
Error 10 error C3861: 'clrscr': identifier not found c:\users\mohammad\documents\visual studio 2013\projects\consoleapplication1\consoleapplication1\consoleapplication1.cpp 44 1 ConsoleApplication1
Error 11 error C2065: 'oldhandler' : undeclared identifier c:\users\mohammad\documents\visual studio 2013\projects\consoleapplication1\consoleapplication1\consoleapplication1.cpp 46 1 ConsoleApplication1
Error 12 error C3861: 'getvect': identifier not found c:\users\mohammad\documents\visual studio 2013\projects\consoleapplication1\consoleapplication1\consoleapplication1.cpp 46 1 ConsoleApplication1
Error 13 error C3861: 'setvect': identifier not found c:\users\mohammad\documents\visual studio 2013\projects\consoleapplication1\consoleapplication1\consoleapplication1.cpp 48 1 ConsoleApplication1
Error 14 error C3861: 'clrscr': identifier not found c:\users\mohammad\documents\visual studio 2013\projects\consoleapplication1\consoleapplication1\consoleapplication1.cpp 67 1 ConsoleApplication1
these errors are related to these lines:
void interrupt handler(__CPPARGS);
void interrupt ( *oldhandler)(__CPPARGS);
and using of: clrscr();
my operation system is windows 10-64bit and its my first time programming in c/c++ in visual studio. I do some in Turbo c++ and devC++ before but only Turbo c++ run this sample and not even devC++. what is the diffrenses and how should I solve this?
thanks
You are working in 64-bit long mode, so you don't have access to real-mode BIOS interrupts or MS-DOS services. Your code has a number of other issues but the bottom line is it's not going to work without a 16-bit compiler and an emulator (like the NTVDM which is absent on 64-bit Windows)

checking internet connection in c++ using internetcheckconnection

I am trying to check internet connection of the user by using internetcheckconnection().
The code:
#include <Wininet.h>
#include <iostream>
#include <string.h>
#include <windows.h>
#pragma comment(lib, "wininet.lib")
int main()
{
char url[128];
strcat(url, "http://www.techtoolbox.com");
bool bConnect = InternetCheckConnection(url, FLAG_ICC_FORCE_CONNECTION, 0);
if (bConnect) {
//internet connection exists !
std::cout << "yes";
}
else {
std::cout << "no ";
}
return 0;
}
But many error are coming up like
29 11 C:\Program Files (x86)\Dev-Cpp\MinGW64\x86_64-w64-mingw32\include\Wininet.h [Error] 'LPVOID' does not name a type
30 11 C:\Program Files (x86)\Dev-Cpp\MinGW64\x86_64-w64-mingw32\include\Wininet.h [Error] 'HINTERNET' does not name a type
32 11 C:\Program Files (x86)\Dev-Cpp\MinGW64\x86_64-w64-mingw32\include\Wininet.h [Error] 'WORD' does not name a type
and 431 more .
I have already installed Wininet.lib, but still these error are coming . It would be kind of you if you could solve this easy problem :) .
LPVOID, HINTERNET and other types from your error messages are declared in windows.h. You should rearrange includes to fix these errors:
#include <windows.h>
#include <Wininet.h>

OpenCV 2.4.8 Code Error in Microsoft Visual C ++ 2010 Express

I am new to to OpenCV and C++ programming.
I recently installed and configure OpenCV 2.4.8 with Visual Studio 2010 through this link:
http://opencv-srf.blogspot.com/2013/05/installing-configuring-opencv-with-vs.html
Then I test if i did make it right by testing this code:
#include "opencv2/highgui/highgui.hpp"
#include "StdAfx.h"
#include <iostream>
using namespace cv;
using namespace std;
int main( int argc, const char** argv )
{
Mat img = imread("C:\Users\jay\Google Drive\profilepic", CV_LOAD_IMAGE_UNCHANGED); //read the image data in the file "MyPic.JPG" and store it in 'img'
if (img.empty()) //check whether the image is loaded or not
{
cout << "Error : Image cannot be loaded..!!" << endl;
//system("pause"); //wait for a key press
return -1;
}
namedWindow("MyWindow", CV_WINDOW_AUTOSIZE); //create a window with the name "MyWindow"
imshow("MyWindow", img); //display the image which is stored in the 'img' in the "MyWindow" window
waitKey(0); //wait infinite time for a keypress
destroyWindow("MyWindow"); //destroy the window with the name, "MyWindow"
return 0;
}
Unfortunately, it gave errors:
1>------ Build started: Project: ConsoleApplication1, Configuration: Debug Win32 ------
1> ConsoleApplication1.cpp
1>c:\users\jay\documents\visual studio 2010\projects\consoleapplication1\consoleapplication1\consoleapplication1.cpp(1): warning C4627: '#include "opencv2/highgui/highgui.hpp"': skipped when looking for precompiled header use
1> Add directive to 'StdAfx.h' or rebuild precompiled header
1>c:\users\jay\documents\visual studio 2010\projects\consoleapplication1\consoleapplication1\consoleapplication1.cpp(5): error C2871: 'cv' : a namespace with this name does not exist
1>c:\users\jay\documents\visual studio 2010\projects\consoleapplication1\consoleapplication1\consoleapplication1.cpp(10): error C2065: 'Mat' : undeclared identifier
1>c:\users\jay\documents\visual studio 2010\projects\consoleapplication1\consoleapplication1\consoleapplication1.cpp(10): error C2146: syntax error : missing ';' before identifier 'img'
1>c:\users\jay\documents\visual studio 2010\projects\consoleapplication1\consoleapplication1\consoleapplication1.cpp(10): error C2065: 'img' : undeclared identifier
1>c:\users\jay\documents\visual studio 2010\projects\consoleapplication1\consoleapplication1\consoleapplication1.cpp(10): warning C4129: 'j' : unrecognized character escape sequence
1>c:\users\jay\documents\visual studio 2010\projects\consoleapplication1\consoleapplication1\consoleapplication1.cpp(10): warning C4129: 'G' : unrecognized character escape sequence
1>c:\users\jay\documents\visual studio 2010\projects\consoleapplication1\consoleapplication1\consoleapplication1.cpp(10): warning C4129: 'p' : unrecognized character escape sequence
1>c:\users\jay\documents\visual studio 2010\projects\consoleapplication1\consoleapplication1\consoleapplication1.cpp(10): error C2065: 'CV_LOAD_IMAGE_UNCHANGED' : undeclared identifier
1>c:\users\jay\documents\visual studio 2010\projects\consoleapplication1\consoleapplication1\consoleapplication1.cpp(10): error C3861: 'imread': identifier not found
1>c:\users\jay\documents\visual studio 2010\projects\consoleapplication1\consoleapplication1\consoleapplication1.cpp(12): error C2065: 'img' : undeclared identifier
1>c:\users\jay\documents\visual studio 2010\projects\consoleapplication1\consoleapplication1\consoleapplication1.cpp(12): error C2228: left of '.empty' must have class/struct/union
1> type is ''unknown-type''
1>c:\users\jay\documents\visual studio 2010\projects\consoleapplication1\consoleapplication1\consoleapplication1.cpp(19): error C2065: 'CV_WINDOW_AUTOSIZE' : undeclared identifier
1>c:\users\jay\documents\visual studio 2010\projects\consoleapplication1\consoleapplication1\consoleapplication1.cpp(19): error C3861: 'namedWindow': identifier not found
1>c:\users\jay\documents\visual studio 2010\projects\consoleapplication1\consoleapplication1\consoleapplication1.cpp(20): error C2065: 'img' : undeclared identifier
1>c:\users\jay\documents\visual studio 2010\projects\consoleapplication1\consoleapplication1\consoleapplication1.cpp(20): error C3861: 'imshow': identifier not found
1>c:\users\jay\documents\visual studio 2010\projects\consoleapplication1\consoleapplication1\consoleapplication1.cpp(22): error C3861: 'waitKey': identifier not found
1>c:\users\jay\documents\visual studio 2010\projects\consoleapplication1\consoleapplication1\consoleapplication1.cpp(24): error C3861: 'destroyWindow': identifier not found
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Hope you can tell me what is wrong with my code.
I am new to this OpenCV thing and C++.
The line
#include "StdAfx.h"
should be first, before any other includes.
That's why the compiler warns you that it skipped the highgui header.

Why do I get "error C2006: '#include' : expected a filename, found 'identifier' "?

My source code in Visual C++ Express 2008 is as follows :
#include “stdafx.h”
#include <iostream>
int _tmain(int argc, _TCHAR* argv[])
{
std::cout << “Hello world!\n”;
return 0;
}
I'm using the book, Visual C++ 2008,by Ivor Horton
.These are the errors that I'm encountering.How do I get rid of the errors ?
1>e:\my documents\visual studio 2008\projects\hello\hello\hello.cpp(1) : error C2006: '#include' : expected a filename, found 'identifier'
1>e:\my documents\visual studio 2008\projects\hello\hello\hello.cpp(1) : fatal error C1083: Cannot open include file: '': No such file or directory
Thanks!
Use double quotes " to surround stdafx.h and Hello world!\n
Currently you are using some inverted quotes/quotation marks.
If you copied the code example directly from your source code, it seems that you have Unicode curly double quotes ( Unicode | U+201C (decimal: 8220) ) when the compiler is expecting ASCII double quotes ( ASCII | 34 (hex: 22 | octal: 0042 | binary: 00100010) | Unicode | U+0022 (decimal: 34) )