Motion Control and Motor Drives

cancel
Showing results for 
Search instead for 
Did you mean: 

About variable definition and build error

I am new to the motion control card. I try to use VC++ to build my application. But after I have done everything written in the examples to add the include and library path, there are still tons of errors when building the application. It seems that the error has something to do with the order of the "#include"s, because changing the order will result in different error codes. But I am not sure what the right order is, and I am not sure whether this is the problem. Any ideas?
 
And if nothing will work, is i32 equals to long in c++? Can I subtitute these types with the corresponding types in C++? Will this solve the problem?
 
Thanks a lot!
 
Part of my codes and error information are as follows:
 
#include "flexmotn.h"
#include "NIMCExample.h"
#include <stdio.h>
#include <time.h>
#include "stdafx.h"
#include "GrindGame.h"
#include "GrindGameDlg.h"
#include <vector>
#include <stdlib.h>
#include "math.h"
#include "engine.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
using namespace std;
i32 xLength;
vector <i32> xPosition, yPosition1, yPosition2;
// global variables
u8 boardID;     // Board identification number
u8 vectorSpace;   // Vector space number
u16 csr = 0;    // Communication status register
u16 axisStatus;   // Axis status
u16 status;
u16 complete;    //Move or blend complete statusi16 adcValue;         // ADC value read
//Variables for modal error handling
u16 commandID;    // The commandID of the function
u16 resourceID;   // The resource ID
i32 errorCode;    // Error code
......
 
Only this small portion has had many errors, such as:
1>e:\docu\visual studio 2005\projects\grindgame\grindgame\grindgamedlg.cpp(68) : error C2146: syntax error : missing ';' before identifier 'xLength'
1>e:\docu\visual studio 2005\projects\grindgame\grindgame\grindgamedlg.cpp(68) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>e:\docu\visual studio 2005\projects\grindgame\grindgame\grindgamedlg.cpp(68) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>e:\docu\visual studio 2005\projects\grindgame\grindgame\grindgamedlg.cpp(69) : error C2923: 'std::vector' : 'i32' is not a valid template type argument for parameter '_Ty'
1>        e:\docu\visual studio 2005\projects\grindgame\grindgame\grindgamedlg.cpp(68) : see declaration of 'i32'
1>e:\docu\visual studio 2005\projects\grindgame\grindgame\grindgamedlg.cpp(75) : error C2146: syntax error : missing ';' before identifier 'boardID'
1>e:\docu\visual studio 2005\projects\grindgame\grindgame\grindgamedlg.cpp(75) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>e:\docu\visual studio 2005\projects\grindgame\grindgame\grindgamedlg.cpp(75) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>e:\docu\visual studio 2005\projects\grindgame\grindgame\grindgamedlg.cpp(76) : error C2146: syntax error : missing ';' before identifier 'vectorSpace'
1>e:\docu\visual studio 2005\projects\grindgame\grindgame\grindgamedlg.cpp(76) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>e:\docu\visual studio 2005\projects\grindgame\grindgame\grindgamedlg.cpp(76) : error C2086: 'int u8' : redefinition
1>        e:\docu\visual studio 2005\projects\grindgame\grindgame\grindgamedlg.cpp(75) : see declaration of 'u8'
1>e:\docu\visual studio 2005\projects\grindgame\grindgame\grindgamedlg.cpp(76) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>e:\docu\visual studio 2005\projects\grindgame\grindgame\grindgamedlg.cpp(77) : error C2146: syntax error : missing ';' before identifier 'csr'
1>e:\docu\visual studio 2005\projects\grindgame\grindgame\grindgamedlg.cpp(77) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>e:\docu\visual studio 2005\projects\grindgame\grindgame\grindgamedlg.cpp(77) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>e:\docu\visual studio 2005\projects\grindgame\grindgame\grindgamedlg.cpp(78) : error C2146: syntax error : missing ';' before identifier 'axisStatus'
1>e:\docu\visual studio 2005\projects\grindgame\grindgame\grindgamedlg.cpp(78) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>e:\docu\visual studio 2005\projects\grindgame\grindgame\grindgamedlg.cpp(78) : error C2086: 'int u16' : redefinition
0 Kudos
Message 1 of 2
(4,351 Views)
bibo,
 
    Your code looks fine in general, but there is something to consider.  According to this document, Visual C++ in .NET is not supported.  But, C code will work within it.
    I would try working from the C examples, which will be in a folder similar to: C:\Program Files\National Instruments\NI-Motion\FlexMotion\Examples\C.  Let me know if you have more questions!  Thank you.
 
-Allison S.
Applications Engineering
-Allison S.
Calibration Services
Product Support Engineer
0 Kudos
Message 2 of 2
(4,329 Views)