2016-11-12 1 views
0

내 위상을 저장하면 다음과 같다배열 등의 구조체를 통과하고

내 구조체는 다음과 같다
enum Gait_cycle_states { 
HEEL_STRIKE, 
FLAT_FOOT, 
MID_STANCE, 
HEEL_OFF, 
TOE_OFF, 
MID_SWING 
}; 

:

struct State { 
Gait_cycle_states current_state; 
uint8_t next_state; //index of the next state 

uint8_t ay_num_criteria; 
State_criterion *ay_criteria_for_state; 

unsigned int gy_num_criteria; 
State_criterion *gy_criteria_for_state; 
}; 

내 기능은 다음과 같다 :

void initialize_FSM(State states_array[]){ 
//Heel strike---------------------------------------------------------- 

State heel_strike = { 
    .current_state = HEEL_STRIKE, 
    .next_state = 1, //the index of the next state 

    .ay_num_criteria = 1, 
    .ay_criteria_for_state = new State_criterion[1], 

    .gy_num_criteria = 2, 
    .gy_criteria_for_state = new State_criterion[2] 
}; 

//The features to look for in accel_y and gyro_y, and how old they can be to count (in ms) 
heel_strike.ay_criteria_for_state[0] = { NO_FEATURE, 150 }; 
heel_strike.gy_criteria_for_state[0] = { NEGATIVE_TROUGH, 150 }; 
heel_strike.gy_criteria_for_state[1] = { BREACHED_HIGH_THRESHOLD, 30 }; 

//putting the state we just configured into the state array 
states_array[0] = heel_strike; 
}; 

Visual Studio 2015에서 "."을 (를) 사용하여 내 유형에 값을 할당하지 않는 것으로 보입니다. 또는 유행에서, 나는 그것을하고있다.

것은 그것은 저에게이 같은 무리 나 오류 및 경고를 던지고있다 :

1>c:\users\arunava nag\documents\visual studio 2015\projects\gaitdetector\gaitdetector\gait_detector.cpp(123): error C2059: syntax error: '.' 
1>c:\users\arunava nag\documents\visual studio 2015\projects\gaitdetector\gaitdetector\gait_detector.cpp(131): error C2143: syntax error: missing ';' before '}' 
1>c:\users\arunava nag\documents\visual studio 2015\projects\gaitdetector\gaitdetector\gait_detector.cpp(134): error C3927: '->': trailing return type is not allowed after a non-function declarator 
1>c:\users\arunava nag\documents\visual studio 2015\projects\gaitdetector\gaitdetector\gait_detector.cpp(134): error C3484: syntax error: expected '->' before the return type 
1>c:\users\arunava nag\documents\visual studio 2015\projects\gaitdetector\gaitdetector\gait_detector.cpp(134): error C3613: missing return type after '->' ('int' assumed) 
1>c:\users\arunava nag\documents\visual studio 2015\projects\gaitdetector\gaitdetector\gait_detector.cpp(134): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
1>c:\users\arunava nag\documents\visual studio 2015\projects\gaitdetector\gaitdetector\gait_detector.cpp(134): error C2146: syntax error: missing ';' before identifier 'ay_criteria_for_state' 
1>c:\users\arunava nag\documents\visual studio 2015\projects\gaitdetector\gaitdetector\gait_detector.cpp(134): error C2143: syntax error: missing ';' before '{' 
1>c:\users\arunava nag\documents\visual studio 2015\projects\gaitdetector\gaitdetector\gait_detector.cpp(134): error C2447: '{': missing function header (old-style formal list?) 
1>c:\users\arunava nag\documents\visual studio 2015\projects\gaitdetector\gaitdetector\gait_detector.cpp(135): error C3927: '->': trailing return type is not allowed after a non-function declarator 
1>c:\users\arunava nag\documents\visual studio 2015\projects\gaitdetector\gaitdetector\gait_detector.cpp(135): error C3484: syntax error: expected '->' before the return type 
1>c:\users\arunava nag\documents\visual studio 2015\projects\gaitdetector\gaitdetector\gait_detector.cpp(135): error C3613: missing return type after '->' ('int' assumed) 
1>c:\users\arunava nag\documents\visual studio 2015\projects\gaitdetector\gaitdetector\gait_detector.cpp(135): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
1>c:\users\arunava nag\documents\visual studio 2015\projects\gaitdetector\gaitdetector\gait_detector.cpp(135): error C2086: 'int heel_strike': redefinition 
1> c:\users\arunava nag\documents\visual studio 2015\projects\gaitdetector\gaitdetector\gait_detector.cpp(134): note: see declaration of 'heel_strike' 
1>c:\users\arunava nag\documents\visual studio 2015\projects\gaitdetector\gaitdetector\gait_detector.cpp(135): error C2146: syntax error: missing ';' before identifier 'gy_criteria_for_state' 
1>c:\users\arunava nag\documents\visual studio 2015\projects\gaitdetector\gaitdetector\gait_detector.cpp(135): error C2143: syntax error: missing ';' before '{' 
1>c:\users\arunava nag\documents\visual studio 2015\projects\gaitdetector\gaitdetector\gait_detector.cpp(135): error C2447: '{': missing function header (old-style formal list?) 
1>c:\users\arunava nag\documents\visual studio 2015\projects\gaitdetector\gaitdetector\gait_detector.cpp(136): error C3927: '->': trailing return type is not allowed after a non-function declarator 
1>c:\users\arunava nag\documents\visual studio 2015\projects\gaitdetector\gaitdetector\gait_detector.cpp(136): error C3484: syntax error: expected '->' before the return type 
1>c:\users\arunava nag\documents\visual studio 2015\projects\gaitdetector\gaitdetector\gait_detector.cpp(136): error C3613: missing return type after '->' ('int' assumed) 
1>c:\users\arunava nag\documents\visual studio 2015\projects\gaitdetector\gaitdetector\gait_detector.cpp(136): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
1>c:\users\arunava nag\documents\visual studio 2015\projects\gaitdetector\gaitdetector\gait_detector.cpp(136): error C2086: 'int heel_strike': redefinition 
1> c:\users\arunava nag\documents\visual studio 2015\projects\gaitdetector\gaitdetector\gait_detector.cpp(134): note: see declaration of 'heel_strike' 
1>c:\users\arunava nag\documents\visual studio 2015\projects\gaitdetector\gaitdetector\gait_detector.cpp(136): error C2146: syntax error: missing ';' before identifier 'gy_criteria_for_state' 
1>c:\users\arunava nag\documents\visual studio 2015\projects\gaitdetector\gaitdetector\gait_detector.cpp(136): error C2143: syntax error: missing ';' before '{' 
1>c:\users\arunava nag\documents\visual studio 2015\projects\gaitdetector\gaitdetector\gait_detector.cpp(136): error C2447: '{': missing function header (old-style formal list?) 

사람이 할 수있는 걸 제안 해주십시오 수 있을까?

답변

1
State heel_strike = { 
    HEEL_STRIKE, 
    1, //the index of the next state 

    1, 
    new State_criterion[1], 

    2, 
    new State_criterion[2] 
}; 

사용하려고하는 것을 "지정된 초기화 프로그램"이라고합니다. 그것들은 표준 C++의 일부가 아닌 C 언어의 특징입니다 (C99 이후). 일부 컴파일러는 C++을 확장으로 지원하지만 MSVC는 지원하지 않습니다.

+0

감사 ... 당신 말이 맞습니다. –

+0

"* (나는 C 코드를 지원하지 않는다.) *"VC++ 2013부터 시작하지만, C로 컴파일 할 때 _only_, C++로 컴파일 할 때 절대로. – ildjarn

+0

@ildjarn 괄호 안의 부분을 제거했습니다. –

관련 문제