Error Using mex matlab 2014a windows x64 - c++

I got several errors while trying to use mex function on matlab 2014a with windows 7 x64. The most simple example of any mex generates the error listed as follows. I used windows 7.1 sdk compiler, vc++ 2010 compiler and vc++ compiler and the error doesn't change a thing. Anyone have experienced this issue as well while using this configurations? I would apreciatte some help with this.
C:\Program Files\MATLAB\R2014a\extern\include\mex.h(37) : error C2143: syntax error : missing ';' before '*'
C:\Program Files\MATLAB\R2014a\extern\include\mex.h(37) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Program Files\MATLAB\R2014a\extern\include\mex.h(37) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Program Files\MATLAB\R2014a\extern\include\mex.h(42) : error C2146: syntax error : missing ';' before identifier 'f'
C:\Program Files\MATLAB\R2014a\extern\include\mex.h(42) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Program Files\MATLAB\R2014a\extern\include\mex.h(42) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Program Files\MATLAB\R2014a\extern\include\mex.h(75) : error C2065: 'mxFunctionPtr' : undeclared identifier
C:\Program Files\MATLAB\R2014a\extern\include\mex.h(75) : error C2146: syntax error : missing ')' before identifier 'f'
C:\Program Files\MATLAB\R2014a\extern\include\mex.h(75) : error C2513: 'const char **' : no variable declared before '='
C:\Program Files\MATLAB\R2014a\extern\include\mex.h(75) : error C2059: syntax error : ')'
C:\Program Files\MATLAB\R2014a\extern\include\mex.h(120) : error C2061: syntax error : identifier 'mxArray'
C:\Program Files\MATLAB\R2014a\extern\include\mex.h(171) : error C2065: 'mxArray' : undeclared identifier
C:\Program Files\MATLAB\R2014a\extern\include\mex.h(172) : error C2065: 'pa' : undeclared identifier
C:\Program Files\MATLAB\R2014a\extern\include\mex.h(172) : error C2182: 'mexMakeArrayPersistent' : illegal use of type 'void'
C:\Program Files\MATLAB\R2014a\extern\include\mex.h(172) : fatal error C1903: unable to recover from previous error(s);
stopping compilation
EDIT 1 :
as Sugested below, all the errors changed to this:
error C2014: preprocessor command must start as first
error C2061: syntax error : identifier 'mxArray'
error C2065: 'nrhs' : undeclared identifier
error C3861: 'mexErrMsgIdAndTxt': identifier not found
error C3861: 'mexErrMsgIdAndTxt': identifier not found
error C2065: 'prhs' : undeclared identifier
error C2065: 'prhs' : undeclared identifier
error C3861: 'mxGetN': identifier not found
error C3861: 'mxGetN': identifier not found
error C3861: 'mexErrMsgIdAndTxt': identifier not found
error C2065: 'prhs' : undeclared identifier
error C3861: 'mxGetN': identifier not found
error C2065: 'prhs' : undeclared identifier
error C3861: 'mxGetPr': identifier not found
error C2065: 'prhs' : undeclared identifier
error C3861: 'mxGetPr': identifier not found
error C2065: 'prhs' : undeclared identifier
error C3861: 'mxGetM': identifier not found
error C2065: 'prhs' : undeclared identifier
error C3861: 'mxGetM': identifier not found
error C2065: 'plhs' : undeclared identifier
error C2065: 'mxREAL' : undeclared identifier
error C3861: 'mxCreateDoubleMatrix': identifier not
error C2065: 'plhs' : undeclared identifier
error C3861: 'mxGetPr': identifier not found
fatal error C1075: end of file found before the left
brace '{' at 'pukkernelMex.cpp(3)' was matched
EDIT 2 - Contents of pukkernel:
#include <stdio.h>
#include <math.h>
extern "C" { #include "mex.h" }
void pukKernel(double *A, double *B, int rowsA, int rowsB, int columns, double *out)
{
double w = 1.0;
double s = 1.0;
double cte1 = 1/s;
double cte2 = sqrt(pow(2,(1/w))-1);
for (int pattA = 0; pattA < rowsA; pattA++) {
for (int pattB = 0; pattB < rowsB; pattB++) {
double norma = 0;
for (int c = 0; c < columns; c++) {
norma += pow(A[pattA+(c)*rowsA] - B[pattB+(c)*rowsB], 2);
}
norma = sqrt(norma);
double de = 2*norma;
double aux = cte1 * de * cte2;
out[pattA+(pattB)*rowsA] = 1 / pow((1+pow(aux,2)), w);
}
}
}
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
if (nrhs != 2) {
mexErrMsgIdAndTxt("Test:pukkernel:nrhs.",
"Two inputs required.");
}
if (nlhs != 1) {
mexErrMsgIdAndTxt("Test:pukkernel:nlhs",
"One output required.");
}
if (mxGetN(prhs[0]) != mxGetN(prhs[1])) {
mexErrMsgIdAndTxt("Test:pukkernel:differentDimensions",
"Input matrixes must have same dimensions.");
}
// Input
int columns = mxGetN(prhs[0]);
double *A = (double *) mxGetPr(prhs[0]);
double *B = (double *) mxGetPr(prhs[1]);
int rowsA = mxGetM(prhs[0]);
int rowsB = mxGetM(prhs[1]);
// Output
plhs[0] = mxCreateDoubleMatrix(rowsA, rowsB, mxREAL);
double *outMatrix = mxGetPr(plhs[0]);
pukKernel(A, B, rowsA, rowsB, columns, outMatrix);
}

Related

TrySubmitThreadpoolCallback undeclared identifier

env
Win10, VC6.0
question
When I use windows default thread pool to submit workers,
It compile error. I use VC6.0, and having included Windows.h
but it can't find the function. Please help me.
main.cpp
#include "main.h"
int KeyMap[128];
int main()
{
ScriptHeadTail* pSht = (ScriptHeadTail*)KeyMap[101];
if (pSht != NULL){
TrySubmitThreadpoolCallback(ProcessHook, (LPVOID)(pSht->head), NULL);
}
Sleep(1000);
return 1;
}
VOID CALLBACK ProcessHook(PTP_CALLBACK_INSTANCE instance, PVOID lParam)
{
ExecuteScript* pScript = (ExecuteScript*)lpParam;
while (pScript != NULL){
switch (pScript->type)
{
case KEYBOARD :
{
printf("send key : %d\n", pScript->value);
break;
}
case LBUTTON :
{
printf("left button down : %d\n", pScript->value);
break;
}
case RBUTTON :
{
break;
}
case IDLE :
{
Sleep(pScript->value);
break;
}
}
pScript = pScript->next;
}
return 1;
}
main.h
#include <Windows.h>
#include <stdio.h>
struct ExecuteScript
{
int type;
int value;
ExecuteScript* next;
};
struct ScriptHeadTail
{
ExecuteScript* head;
ExecuteScript* tail;
};
BOOL Init(LPCSTR configFile);
BOOL LoadConfigFile(const char* configFile);
VOID CALLBACK ProcessHook(PTP_CALLBACK_INSTANCE instance, PVOID lParam);
const int ASCII_LEN = 128;
const int KEYBOARD = 1;
const int LBUTTON = 2;
const int RBUTTON = 3;
const int IDLE = 4;
result
--------------------Configuration: ReadFileTest - Win32 Debug---------- ----------
Compiling...
main.cpp
c:\users\jasey\windows-program\readfiletest\main.h(20) : error C2065: 'PTP_CALLBACK_INSTANCE' : undeclared identifier
c:\users\jasey\windows-program\readfiletest\main.h(20) : error C2146: syntax error : missing ')' before identifier 'instance'
c:\users\jasey\windows-program\readfiletest\main.h(20) : warning C4229: anachronism used : modifiers on data are ignored
c:\users\jasey\windows-program\readfiletest\main.h(20) : error C2182: 'ProcessHook' : illegal use of type 'void'
c:\users\jasey\windows-program\readfiletest\main.h(20) : error C2059: syntax error : ')'
c:\users\jasey\windows-program\readfiletest\main.cpp(13) : error C2065: 'TrySubmitThreadpoolCallback' : undeclared identifier
c:\users\jasey\windows-program\readfiletest\main.cpp(60) : error C2146: syntax error : missing ')' before identifier 'instance'
c:\users\jasey\windows-program\readfiletest\main.cpp(60) : warning C4229: anachronism used : modifiers on data are ignored
c:\users\jasey\windows-program\readfiletest\main.cpp(60) : error C2182: 'ProcessHook' : illegal use of type 'void'
c:\users\jasey\windows-program\readfiletest\main.cpp(60) : error C2086: 'ProcessHook' : redefinition
c:\users\jasey\windows-program\readfiletest\main.cpp(60) : error C2059: syntax error : ')'
c:\users\jasey\windows-program\readfiletest\main.cpp(61) : error C2143: syntax error : missing ';' before '{'
c:\users\jasey\windows-program\readfiletest\main.cpp(61) : error C2447: missing function header (old-style formal list?)
执行 cl.exe 时出错.
Creating browse info file...
ReadFileTest.exe - 1 error(s), 0 warning(s)
That API was introduced in Windows Vista. Latest Windows SDK supported in VC 6 is for windows server 2003, it's older than Vista.
Best way to fix is upgrade Visual C++ to some newer version.

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)

What's the deal with BOOST_FUSION_ADAPT_STRUCT with more than 64 members?

Trying to create boilerplate code for a huge struct with more than 64 members and the BOOST_FUSION_ADAPT_STRUCT macro but it fails to compile in VS2015 Update 3. I've tried to play with BOOST_FUSION_HAS_VARIADIC_VECTOR and BOOST_PP_LIMIT_TUPLE but no luck, I keep getting the same error if I add more than 64 members to BOOST_FUSION_ADAPT_STRUCT. Did not find any mention of limits the BOOST_FUSION_ADAPT_STRUCT has except when it is in C++03 mode. Am I missing something?
Live at Coliru
Code:
#include <boost/fusion/adapted/struct/adapt_struct.hpp>
struct Data
{
int a01 = 1;
int a02 = 1;
int a03 = 1;
int a04 = 1;
int a05 = 1;
int a06 = 1;
int a07 = 1;
int a08 = 1;
int a09 = 1;
int a10 = 1;
int a11 = 1;
int a12 = 1;
int a13 = 1;
int a14 = 1;
int a15 = 1;
int a16 = 1;
int a17 = 1;
int a18 = 1;
int a19 = 1;
int a20 = 1;
int a21 = 1;
int a22 = 1;
int a23 = 1;
int a24 = 1;
int a25 = 1;
int a26 = 1;
int a27 = 1;
int a28 = 1;
int a29 = 1;
int a30 = 1;
int a31 = 1;
int a32 = 1;
int a33 = 1;
int a34 = 1;
int a35 = 1;
int a36 = 1;
int a37 = 1;
int a38 = 1;
int a39 = 1;
int a40 = 1;
int a41 = 1;
int a42 = 1;
int a43 = 1;
int a44 = 1;
int a45 = 1;
int a46 = 1;
int a47 = 1;
int a48 = 1;
int a49 = 1;
int a50 = 1;
int a51 = 1;
int a52 = 1;
int a53 = 1;
int a54 = 1;
int a55 = 1;
int a56 = 1;
int a57 = 1;
int a58 = 1;
int a59 = 1;
int a60 = 1;
int a61 = 1;
int a62 = 1;
int a63 = 1;
int a64 = 1;
int a65 = 1;
int a66 = 1;
int a67 = 1;
int a68 = 1;
int a69 = 1;
int a70 = 1;
};
BOOST_FUSION_ADAPT_STRUCT(Data, a01, a02, a03, a04, a05, a06, a07, a08, a09, a10, a11, a12, a13, a14, a15, a16, a17,
a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36,
a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55,
a56, a57, a58, a59, a60, a61, a62, a63/*, a64, a65, a66, a67, a68, a69, a70*/) // uncomment the a64 to get the error
int main()
{
return 0;
}
MSVC errors:
1>consoleapplication23.cpp(119): warning C4003: not enough actual
parameters for macro 'BOOST_PP_SEQ_ELEM_III'
1>consoleapplication23.cpp(119): error C2065: 'BOOST_PP_SEQ_ELEM_0':
undeclared identifier 1>consoleapplication23.cpp(119): error C2146:
syntax error: missing '>' before identifier
'BOOST_PP_TUPLE_TO_SEQ_a64' 1>consoleapplication23.cpp(119): error
C2065: 'a01': undeclared identifier 1>consoleapplication23.cpp(119):
error C2065: 'a02': undeclared identifier
1>consoleapplication23.cpp(119): error C2065: 'a03': undeclared
identifier 1>consoleapplication23.cpp(119): error C2065: 'a04':
undeclared identifier 1>consoleapplication23.cpp(119): error C2065:
'a05': undeclared identifier 1>consoleapplication23.cpp(119): error
C2065: 'a06': undeclared identifier 1>consoleapplication23.cpp(119):
error C2065: 'a07': undeclared identifier
1>consoleapplication23.cpp(119): error C2065: 'a08': undeclared
identifier 1>consoleapplication23.cpp(119): error C2065: 'a09':
undeclared identifier 1>consoleapplication23.cpp(119): error C2065:
'a10': undeclared identifier 1>consoleapplication23.cpp(119): error
C2065: 'a11': undeclared identifier 1>consoleapplication23.cpp(119):
error C2065: 'a12': undeclared identifier
1>consoleapplication23.cpp(119): error C2065: 'a13': undeclared
identifier 1>consoleapplication23.cpp(119): error C2065: 'a14':
undeclared identifier 1>consoleapplication23.cpp(119): error C2065:
'a15': undeclared identifier 1>consoleapplication23.cpp(119): error
C2065: 'a16': undeclared identifier 1>consoleapplication23.cpp(119):
error C2065: 'a17': undeclared identifier
1>consoleapplication23.cpp(119): error C2065: 'a18': undeclared
identifier 1>consoleapplication23.cpp(119): error C2065: 'a19':
undeclared identifier 1>consoleapplication23.cpp(119): error C2065:
'a20': undeclared identifier 1>consoleapplication23.cpp(119): error
C2065: 'a21': undeclared identifier 1>consoleapplication23.cpp(119):
error C2065: 'a22': undeclared identifier
1>consoleapplication23.cpp(119): error C2065: 'a23': undeclared
identifier 1>consoleapplication23.cpp(119): error C2065: 'a24':
undeclared identifier 1>consoleapplication23.cpp(119): error C2065:
'a25': undeclared identifier 1>consoleapplication23.cpp(119): error
C2065: 'a26': undeclared identifier 1>consoleapplication23.cpp(119):
error C2065: 'a27': undeclared identifier
1>consoleapplication23.cpp(119): error C2065: 'a28': undeclared
identifier 1>consoleapplication23.cpp(119): error C2065: 'a29':
undeclared identifier 1>consoleapplication23.cpp(119): error C2065:
'a30': undeclared identifier 1>consoleapplication23.cpp(119): error
C2065: 'a31': undeclared identifier 1>consoleapplication23.cpp(119):
error C2065: 'a32': undeclared identifier
1>consoleapplication23.cpp(119): error C2065: 'a33': undeclared
identifier 1>consoleapplication23.cpp(119): error C2065: 'a34':
undeclared identifier 1>consoleapplication23.cpp(119): error C2065:
'a35': undeclared identifier 1>consoleapplication23.cpp(119): error
C2065: 'a36': undeclared identifier 1>consoleapplication23.cpp(119):
error C2065: 'a37': undeclared identifier
1>consoleapplication23.cpp(119): error C2065: 'a38': undeclared
identifier 1>consoleapplication23.cpp(119): error C2065: 'a39':
undeclared identifier 1>consoleapplication23.cpp(119): error C2065:
'a40': undeclared identifier 1>consoleapplication23.cpp(119): error
C2065: 'a41': undeclared identifier 1>consoleapplication23.cpp(119):
error C2065: 'a42': undeclared identifier
1>consoleapplication23.cpp(119): error C2065: 'a43': undeclared
identifier 1>consoleapplication23.cpp(119): error C2065: 'a44':
undeclared identifier 1>consoleapplication23.cpp(119): error C2065:
'a45': undeclared identifier 1>consoleapplication23.cpp(119): error
C2065: 'a46': undeclared identifier 1>consoleapplication23.cpp(119):
error C2065: 'a47': undeclared identifier
1>consoleapplication23.cpp(119): error C2065: 'a48': undeclared
identifier 1>consoleapplication23.cpp(119): error C2065: 'a49':
undeclared identifier 1>consoleapplication23.cpp(119): error C2065:
'a50': undeclared identifier 1>consoleapplication23.cpp(119): error
C2065: 'a51': undeclared identifier 1>consoleapplication23.cpp(119):
error C2065: 'a52': undeclared identifier
1>consoleapplication23.cpp(119): error C2065: 'a53': undeclared
identifier 1>consoleapplication23.cpp(119): error C2065: 'a54':
undeclared identifier 1>consoleapplication23.cpp(119): error C2065:
'a55': undeclared identifier 1>consoleapplication23.cpp(119): error
C2065: 'a56': undeclared identifier 1>consoleapplication23.cpp(119):
error C2065: 'a57': undeclared identifier
1>consoleapplication23.cpp(119): error C2065: 'a58': undeclared
identifier 1>consoleapplication23.cpp(119): error C2065: 'a59':
undeclared identifier 1>consoleapplication23.cpp(119): error C2065:
'a60': undeclared identifier 1>consoleapplication23.cpp(119): error
C2065: 'a61': undeclared identifier 1>consoleapplication23.cpp(119):
error C2065: 'a62': undeclared identifier
1>consoleapplication23.cpp(119): error C2065: 'a63': undeclared
identifier 1>consoleapplication23.cpp(119): error C2065: 'a64':
undeclared identifier 1>consoleapplication23.cpp(119): error C2065:
'a65': undeclared identifier 1>consoleapplication23.cpp(119): error
C2065: 'a66': undeclared identifier 1>consoleapplication23.cpp(119):
error C2065: 'a67': undeclared identifier
1>consoleapplication23.cpp(119): error C2065: 'a68': undeclared
identifier 1>consoleapplication23.cpp(119): error C2065: 'a69':
undeclared identifier 1>consoleapplication23.cpp(119): error C2065:
'a70': undeclared identifier 1>consoleapplication23.cpp(116): error
C2059: syntax error: ')' 1>consoleapplication23.cpp(119): error C2977:
'boost::fusion::traits::tag_of': too many template arguments 1>
packages\boost.1.61.0.0\lib\native\include\boost\fusion\support\tag_of.hpp(71):
note: see declaration of 'boost::fusion::traits::tag_of'
1>consoleapplication23.cpp(119): error C2913: explicit specialization;
'boost::fusion::traits::tag_of' is not a specialization of a class
template 1>consoleapplication23.cpp(119): error C2913: explicit
specialization; 'boost::fusion::traits::tag_of' is not a
specialization of a class template 1>consoleapplication23.cpp(119):
error C4430: missing type specifier - int assumed. Note: C++ does not
support default-int 1>consoleapplication23.cpp(119): error C2440:
'initializing': cannot convert from 'initializer list' to 'int' 1>
consoleapplication23.cpp(119): note: The initializer contains too many
elements 1>consoleapplication23.cpp(116): error C2059: syntax error:
'(' 1>consoleapplication23.cpp(119): error C2065:
'BOOST_PP_SEQ_ELEM_0': undeclared identifier
1>consoleapplication23.cpp(119): error C2146: syntax error: missing
'>' before identifier 'BOOST_PP_TUPLE_TO_SEQ_a64'
1>consoleapplication23.cpp(119): error C2065: 'a01': undeclared
identifier 1>consoleapplication23.cpp(119): error C2065: 'a02':
undeclared identifier 1>consoleapplication23.cpp(119): error C2065:
'a03': undeclared identifier 1>consoleapplication23.cpp(119): error
C2065: 'a04': undeclared identifier 1>consoleapplication23.cpp(119):
error C2065: 'a05': undeclared identifier
1>consoleapplication23.cpp(119): error C2065: 'a06': undeclared
identifier 1>consoleapplication23.cpp(119): error C2065: 'a07':
undeclared identifier 1>consoleapplication23.cpp(119): error C2065:
'a08': undeclared identifier 1>consoleapplication23.cpp(119): error
C2065: 'a09': undeclared identifier 1>consoleapplication23.cpp(119):
error C2065: 'a10': undeclared identifier
1>consoleapplication23.cpp(119): error C2065: 'a11': undeclared
identifier 1>consoleapplication23.cpp(119): error C2065: 'a12':
undeclared identifier 1>consoleapplication23.cpp(119): error C2065:
'a13': undeclared identifier 1>consoleapplication23.cpp(119): error
C2065: 'a14': undeclared identifier 1>consoleapplication23.cpp(119):
error C2065: 'a15': undeclared identifier
1>consoleapplication23.cpp(119): error C2065: 'a16': undeclared
identifier 1>consoleapplication23.cpp(119): error C2065: 'a17':
undeclared identifier 1>consoleapplication23.cpp(119): error C2065:
'a18': undeclared identifier 1>consoleapplication23.cpp(119): error
C2065: 'a19': undeclared identifier 1>consoleapplication23.cpp(119):
error C2065: 'a20': undeclared identifier
1>consoleapplication23.cpp(119): error C2065: 'a21': undeclared
identifier 1>consoleapplication23.cpp(119): fatal error C1003: error
count exceeds 100; stopping compilation
GCC errors:
main.cpp:80:1: error: macro "BOOST_PP_SEQ_ELEM_III" requires 2
arguments, but only 1 given
a56, a57, a58, a59, a60, a61, a62, a63, a64, a65, a66, a67, a68, a69, a70) // uncomment the a64 to get the
error ^ In file included from
/usr/local/include/boost/preprocessor/seq/seq.hpp:16:0,
from /usr/local/include/boost/fusion/adapted/struct/adapt_struct.hpp:20,
from main.cpp:1: main.cpp:77:1: error: 'BOOST_PP_SEQ_ELEM_III' was not declared in this scope
BOOST_FUSION_ADAPT_STRUCT(Data, a01, a02, a03, a04, a05, a06, a07,
a08, a09, a10, a11, a12, a13, a14, a15, a16, a17, ^ In file included
from
/usr/local/include/boost/fusion/adapted/struct/adapt_struct.hpp:28:0,
from main.cpp:1: main.cpp:77:1: error: template argument 1 is invalid BOOST_FUSION_ADAPT_STRUCT(Data, a01, a02, a03,
a04, a05, a06, a07, a08, a09, a10, a11, a12, a13, a14, a15, a16, a17,
^ In file included from
/usr/local/include/boost/preprocessor/seq/seq.hpp:16:0,
from /usr/local/include/boost/fusion/adapted/struct/adapt_struct.hpp:20,
from main.cpp:1: main.cpp:77:1: error: 'BOOST_PP_SEQ_ELEM_III' was not declared in this scope
BOOST_FUSION_ADAPT_STRUCT(Data, a01, a02, a03, a04, a05, a06, a07,
a08, a09, a10, a11, a12, a13, a14, a15, a16, a17, ^ In file included
from
/usr/local/include/boost/fusion/adapted/struct/adapt_struct.hpp:28:0,
from main.cpp:1: main.cpp:77:1: error: template argument 1 is invalid BOOST_FUSION_ADAPT_STRUCT(Data, a01, a02, a03,
a04, a05, a06, a07, a08, a09, a10, a11, a12, a13, a14, a15, a16, a17,
^ In file included from
/usr/local/include/boost/preprocessor/control/if.hpp:18:0,
from /usr/local/include/boost/fusion/adapted/struct/adapt_struct.hpp:17,
from main.cpp:1: main.cpp:77:1: error: 'BOOST_PP_IIF_0' does not name a type BOOST_FUSION_ADAPT_STRUCT(Data,
a01, a02, a03, a04, a05, a06, a07, a08, a09, a10, a11, a12, a13, a14,
a15, a16, a17, ^ In file included from
/usr/local/include/boost/preprocessor/seq/seq.hpp:16:0,
from /usr/local/include/boost/fusion/adapted/struct/adapt_struct.hpp:20,
from main.cpp:1: main.cpp:77:1: error: 'BOOST_PP_SEQ_ELEM_III' was not declared in this scope
BOOST_FUSION_ADAPT_STRUCT(Data, a01, a02, a03, a04, a05, a06, a07,
a08, a09, a10, a11, a12, a13, a14, a15, a16, a17, ^ In file included
from
/usr/local/include/boost/fusion/adapted/struct/adapt_struct.hpp:28:0,
from main.cpp:1: main.cpp:77:1: error: template argument 1 is invalid BOOST_FUSION_ADAPT_STRUCT(Data, a01, a02, a03,
a04, a05, a06, a07, a08, a09, a10, a11, a12, a13, a14, a15, a16, a17,
^ In file included from
/usr/local/include/boost/preprocessor/seq/seq.hpp:16:0,
from /usr/local/include/boost/fusion/adapted/struct/adapt_struct.hpp:20,
from main.cpp:1: main.cpp:77:1: error: 'BOOST_PP_SEQ_ELEM_III' was not declared in this scope
BOOST_FUSION_ADAPT_STRUCT(Data, a01, a02, a03, a04, a05, a06, a07,
a08, a09, a10, a11, a12, a13, a14, a15, a16, a17, ^ In file included
from
/usr/local/include/boost/fusion/adapted/struct/adapt_struct.hpp:28:0,
from main.cpp:1: main.cpp:77:1: error: template argument 1 is invalid BOOST_FUSION_ADAPT_STRUCT(Data, a01, a02, a03,
a04, a05, a06, a07, a08, a09, a10, a11, a12, a13, a14, a15, a16, a17,
^ In file included from
/usr/local/include/boost/preprocessor/seq/seq.hpp:16:0,
from /usr/local/include/boost/fusion/adapted/struct/adapt_struct.hpp:20,
from main.cpp:1: main.cpp:77:1: error: 'BOOST_PP_SEQ_ELEM_III' was not declared in this scope
BOOST_FUSION_ADAPT_STRUCT(Data, a01, a02, a03, a04, a05, a06, a07,
a08, a09, a10, a11, a12, a13, a14, a15, a16, a17, ^ In file included
from
/usr/local/include/boost/fusion/adapted/struct/adapt_struct.hpp:28:0,
from main.cpp:1: main.cpp:77:1: error: template argument 1 is invalid BOOST_FUSION_ADAPT_STRUCT(Data, a01, a02, a03,
a04, a05, a06, a07, a08, a09, a10, a11, a12, a13, a14, a15, a16, a17,
^
g++ -std=c++14 -O2 -Wall -pedantic -pthread main.cpp && ./a.out
It looks like BOOST_FUSION_ADAPT_STRUCT has two parameters per class element, type and name. MSVC only supports 127 macro parameters while the Standard recommends 255. This explains why the 64'th element, requiring 128 macro parameters, fails to compile on MSVC++.
This happens because BOOST_PP_TUPLE_TO_SEQ() is only implemented for 0 to 64 arguments (one of which is taken by the type in BOOST_FUSION_ADAPT_STRUCT()).
Ref: https://www.boost.org/doc/libs/1_67_0/boost/preprocessor/tuple/to_seq.hpp
As a workaround, you can put some of your struct members into their own struct, and use that struct type as a member in the outer struct. This lets you call BOOST_FUSION_ADAPT_STRUCT() twice: once for each inner struct type, and once for the outer. This easily gives you 63*63 = 3969 maximum fields.
You can avoid this limitation of BOOST_PP_TUPLE_TO_SEQ() if you call the version without BOOST_PP_VARIADICS support
BOOST_FUSION_ADAPT_STRUCT(Data,
(auto,a01)(auto,a02)(auto,a03)(auto,a04)(auto,a05)(auto,a06)(auto,a07)(auto,a08)(auto,a09)(auto,a10)
(auto,a11)(auto,a12)(auto,a13)(auto,a14)(auto,a15)(auto,a16)(auto,a17)(auto,a18)(auto,a19)(auto,a20)
(auto,a21)(auto,a22)(auto,a23)(auto,a24)(auto,a25)(auto,a26)(auto,a27)(auto,a28)(auto,a29)(auto,a30)
(auto,a31)(auto,a32)(auto,a33)(auto,a34)(auto,a35)(auto,a36)(auto,a37)(auto,a38)(auto,a39)(auto,a40)
(auto,a41)(auto,a42)(auto,a43)(auto,a44)(auto,a45)(auto,a46)(auto,a47)(auto,a48)(auto,a49)(auto,a50)
(auto,a51)(auto,a52)(auto,a53)(auto,a54)(auto,a55)(auto,a56)(auto,a57)(auto,a58)(auto,a59)(auto,a60)
(auto,a61)(auto,a62)(auto,a63)(auto,a64)(auto,a65)(auto,a66)(auto,a67)(auto,a68)(auto,a69)(auto,a70))
I could not test it with MSVC but it works with gcc.

Compiler does not recognize OpenCV library

I am using Visual studio 2013 and opencv 3.0.0.
I would like to run this code:
#include <opencv\cv.h>
#include <opencv\highgui.h>
using namespace cv;
int main(){
//Generate matrix to store image
Mat image;
//initialize capture
VideoCapture cap;
cap.open(0);
//Create window to show image
namedWindow("window", 1);
while (1){
//copy webcam stream to image
cap >> image;
//print image to screen
imshow("window", image);
//delay 33ms
waitKey(33);
}
}
However, I got the following errors:
first.cpp(12): error C2065: 'VideoCapture' : undeclared identifier
1>first.cpp(12): error C2146: syntax error : missing ';' before identifier 'cap'
1>first.cpp(12): error C2065: 'cap' : undeclared identifier
1>first.cpp(13): error C2065: 'cap' : undeclared identifier
1>first.cpp(13): error C2228: left of '.open' must have class/struct/union
1> type is 'unknown-type'
1>first.cpp(16): error C3861: 'namedWindow': identifier not found
1>first.cpp(20): error C2065: 'cap' : undeclared identifier
1>first.cpp(23): error C3861: 'imshow': identifier not found
1>first.cpp(26): error C3861: 'waitKey': identifier not found
1>
1>Build FAILED.
I linked the library conveniently. The compiler receives the opencv library. However, it gives such errors.

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.