Ошибка c2144 синтаксическая ошибка перед void требуется

I am getting a bunch of errors as follows:-

Error   1   error C2144: syntax error : 'void' should be preceded by ';'    c:program filesmicrosoft sdkswindowsv6.0aincludeglgl.h   1152    Viewer
Error   2   error C4430: missing type specifier - int assumed. Note: C++ does not support default-int   c:program filesmicrosoft sdkswindowsv6.0aincludeglgl.h   1152    Viewer
Error   3   error C2146: syntax error : missing ';' before identifier 'glAccum' c:program filesmicrosoft sdkswindowsv6.0aincludeglgl.h   1152    Viewer
Error   4   error C2182: 'APIENTRY' : illegal use of type 'void'    c:program filesmicrosoft sdkswindowsv6.0aincludeglgl.h   1152    Viewer
Error   5   error C4430: missing type specifier - int assumed. Note: C++ does not support default-int   c:program filesmicrosoft sdkswindowsv6.0aincludeglgl.h   1152    Viewer
Error   6   error C2144: syntax error : 'void' should be preceded by ';'    c:program filesmicrosoft sdkswindowsv6.0aincludeglgl.h   1153    Viewer
Error   7   error C4430: missing type specifier - int assumed. Note: C++ does not support default-int   c:program filesmicrosoft sdkswindowsv6.0aincludeglgl.h   1153    Viewer

This is all that I include in the beginning of my code :-

#include <cstdlib>
#include <windows.h>
#include <GL/glut.h>
#include <cmath>
#include "arcball.h"
#include <vector>
#include <iostream>
#include <fstream>


using namespace std;

It is interesting though that when I click on the first error it points me to the line

WINGDIAPI void APIENTRY glAccum (GLenum op, GLfloat value);

in gl.h .I am not even including that file.Where are the errors coming from?

PS. dont know if itis important but I have saved the file as a .cpp.

Ok this is weird but I completely remove all the headers and it still shows me this error!!

Виталий 81

1

03.10.2010, 18:42. Показов 3454. Ответов 2

Метки нет (Все метки)


Студворк — интернет-сервис помощи студентам

кто подскажет как исправить ошибку-1>c:program filesmicrosoft visual studio 10.0vcincludeconio.h(21): error C2144: синтаксическая ошибка: перед «int» требуется «;»
Программа на С++2010

C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// 21.cpp: определяет точку входа для консольного приложения.
 
 
#include "stdafx.h"
#include <iostream>
    using std::cin
#include <conio.h>
 
using namespace std;
//#define N 100
#include <stdio.h>
;int N=100;
;int i,j;
 
;int A[100],B[100];
 
//
void main()
{
using std::endl;
cout<<"Enter elements of array А(numeric):"<<endl;
 for(i = 0; i < N; i++)
 {
   cout<<"A["<<i<<"]=";
   cin>>A[i];
 }
 for(i = N-1, j = 0; i > -1; i--, j++)
 {
   B[j] = A[i];
 }
 for(i = 0; i < N; i++)
 {
   cout<<"A["<<i<<"]="<<A[i];
   cout<<"   ";
   cout<<"B["<<i<<"]="<<B[i];
   cout<<endl;
 
 }
 getch();
}

Bazan

22 / 22 / 4

Регистрация: 15.04.2009

Сообщений: 100

03.10.2010, 18:47

2

Поставьте ; после

C++
1
using std::cin



1



Виталий 81

03.10.2010, 18:56

3

Спасибо БАААльшое за помощь заработала

    #include <stdlib.h>

    /* подключаем библиотеку GLUT */

    #include <oglglut.h>

    /* начальная ширина и высота окна */

    GLint Width = 512, Height = 512;

    /* размер куба */

    const int CubeSize = 200;

    /* эта функция управляет всем выводом на экран */

    void Display(void)

    {

        int left, right, top, bottom;

        left  = (Width — CubeSize) / 2;

        right = left + CubeSize;

        bottom = (Height — CubeSize) / 2;

        top = bottom + CubeSize;

        glClearColor(0, 0, 0, 1);

        glClear(GL_COLOR_BUFFER_BIT);

        glColor3ub(255,0,0);

        glBegin(GL_QUADS);

          glVertex2f(left,bottom);

          glVertex2f(left,top);

          glVertex2f(right,top);

          glVertex2f(right,bottom);

        glEnd();

        glFinish();

    }

    /* Функция вызывается при изменении размеров окна */

    void Reshape(GLint w, GLint h)

    {

        Width = w;

        Height = h;

        /* устанавливаем размеры области отображения */

        glViewport(0, 0, w, h);

        /* ортографическая проекция */

        glMatrixMode(GL_PROJECTION);

        glLoadIdentity();

        glOrtho(0, w, 0, h, -1.0, 1.0);

        glMatrixMode(GL_MODELVIEW);

        glutLoadIdentity();

    }

    /* Функция обрабатывает сообщения от клавиатуры */

    void Keyboard(unsigned char key, int x, int y)

    {

    #define ESCAPE ’33’

        if( key == ESCAPE )

            exit(0);

    }

    /* Главный цикл приложения */

    main(int argc, char *argv[])

    {

        glutInit(&argc, argv);

        glutInitDisplayMode(GLUT_RGB);

        glutInitWindowSize(Width, Height);

        glutCreateWindow(«Red square example»);

        glutDisplayFunc(Display);

        glutReshapeFunc(Reshape);

        glutKeyboardFunc(Keyboard);

        glutMainLoop();

    }

  • Remove From My Forums
  • Question

  • I have a simple typedef like this:

    typedef void* OurVar;

    I know this has worked in other projects, but in this one I am currently working on, when the compiler comes across this I see

    error C2144: syntax error : ‘void’ should be preceded by ‘;’

    error C4430: missing type specifier — int assumed. Note: C++ does not support default-int

    I am not sure where to even look.  This is happening with other typedef’s as well.

Answers

  • The error is certainly in the code just above this line.

    • Marked as answer by

      Wednesday, April 11, 2012 11:08 PM

  • On 4/11/2012 2:17 PM, msnhelpsme wrote:

    In other words, I want VS’s path from first include file to the one giving the error.

    I’m not sure what you want, but see if this helps: Project | Properties | C/C++ | Advanced | Show Includes = Yes


    Igor Tandetnik

    • Marked as answer by
      msnhelpsme
      Wednesday, April 11, 2012 11:07 PM

Hi guys,

i have a small question. I have my project and I have I90ControllerDlg.cpp.This is you can say my main. I have another .cpp file called multipoletutorial.cpp that I added to my project tree. I already compile it and everything is ok, so it is compiling the multipoletutorial.cpp file. Now in this file I have a function void cica (void). I tried to call this function in my main program, after I declare it at the begining. When calling it, I set a breackpoint so I can go inside to see what is happening …but it seems that the program when debuging it «changes» automatically the position of the  breackpoint to the next line. So I can never go inside.

I will post  multipoletutorila.cpp file.

In my main file I wrote like this at the begining of the program

using namespace std;
void cica(void);
So I declared it.

and then I tried to call it
cica ();
or cica(void);
and it gives me error
 error C2144: syntax error : ‘void’ should be preceded by ‘)’

So it does not recognize it?

I made another .cpp file and I had a function there and when calling it , it works, but this new one seems not to work.
Please give me a solution.

// Copyright (C) 2003
// Gerhard Neumann (gneumann@gmx.net)
// Stephan Neumann (sneumann@gmx.net) 
//                
// This file is part of RL Toolbox.
// http://www.igi.tugraz.at/ril_toolbox
//
// All rights reserved.
// 
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
//    notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
//    notice, this list of conditions and the following disclaimer in the
//    documentation and/or other materials provided with the distribution.
// 3. The name of the author may not be used to endorse or promote products
//    derived from this software without specific prior written permission.
// 
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
// IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 
/*****************************************************************************************************
Tutorial for the Reinforcement Learning Toolbox. In this example the Pole Balancing task is learned with
a Q-Learning algorithm. For discretization build-in single state discretizer are used. 
The task is learned until the agent manages to pole the cart for over 100000 steps or for 500 episodes.
******************************************************************************************************/
#include "stdafx.h"
#include <time.h>
#include "ril_debug.h"
//#include "cmultipolemodel.h"
#include "robotlearning.h"
//#include "robotlearning.cpp"
#include "ctdlearner.h"
#include "cpolicies.h"
#include "cagent.h"
 
#define one_degree 0.0174532	/* 2pi/360 */
#define six_degrees 0.1047192
#define twelve_degrees 0.2094384
#define fifty_degrees 0.87266
//#define degree 60
//#define time 1000
//#define myforce 0
 
CMultiPoleAction mywrapper(rlt_real myforce,double degree, short time1)
{
	CEnvironmentModel *model1 = NULL;
	CAgentStatisticController *detController1 = NULL;
	CAbstractStateDiscretizer *discState1 = NULL;
	CRewardFunction *rewardFunction1 = NULL;
	CAgent *agent1;
 
 
   CMultiPoleAction myaction(myforce);
	//CMultiPoleAction1 myaction();
 
    //time = xxxx;
     myaction.TurnDegree(degree, time1);
     
     
    
     return myaction;
}
 
void cica(void)
{
	 rlt_real myforce;  
	double degree;
	short time1;
	
 CMultiPoleAction myact; 
  myact = mywrapper(19,60,100);
 
	// initialize the random generator
	srand((unsigned int)time((time_t *)NULL));
 
	// variable declaration
	CEnvironmentModel *model = NULL;
	CAgentStatisticController *detController = NULL;
	CAbstractStateDiscretizer *discState = NULL;
	CRewardFunction *rewardFunction = NULL;
	CAgent *agent;
 
	// create the discretizer with the build in classes
	// create the partition arrays
	double partitions1[] = {-0.8, 0.8}; // partition for x
	double partitions2[] = {-0.5, 0.5}; // partition for x_dot
	double partitions3[] = {-six_degrees, -one_degree, 0, one_degree, six_degrees}; // partition for theta
	double partitions4[] = {-fifty_degrees, fifty_degrees}; // partition for theta_dot
	double partitions5[] = {-fifty_degrees, fifty_degrees}; // partition for theta_dot
 
	// Create the discretizer for the state variables
	CAbstractStateDiscretizer *disc1 = new CSingleStateDiscretizer(0, 2, partitions1);
	CAbstractStateDiscretizer *disc2 = new CSingleStateDiscretizer(1, 2, partitions2);
	CAbstractStateDiscretizer *disc3 = new CSingleStateDiscretizer(2, 7, partitions3);
	CAbstractStateDiscretizer *disc4 = new CSingleStateDiscretizer(3, 2, partitions4);
 
	// Merge the 4 discretizer
	CDiscreteStateOperatorAnd *andCalculator = new CDiscreteStateOperatorAnd();
 
	andCalculator->addStateModifier(disc1);
	andCalculator->addStateModifier(disc2);
	andCalculator->addStateModifier(disc3);
	andCalculator->addStateModifier(disc4);
 
	// Create the failed state discretizer, which distinguishes the state in "failed" and "not failed"
	discState = new CMultiPoleFailedState();
	discState->addStateSubstitution(1, andCalculator);
 
	// create the model
	//model = new CMultiPoleModel(discState);
	model = new CMultiPoleModel();
	// iniialise the reward function
	/* reward function and model are merged*/
	rewardFunction = (CMultiPoleModel *)model;
 
	// create the agent
	agent = new CAgent(model); 
	
	// create the 2 actions for accelearting the cart and add them to the agent's action set
	//CPrimitiveAction *primAction1 = new CMultiPoleAction(10.0, discState);
	//CPrimitiveAction *primAction2 = new CMultiPoleAction(-10.0, discState);
	CPrimitiveAction *primAction1 = new CMultiPoleAction(10.0);
	CPrimitiveAction *primAction2 = new CMultiPoleAction(-10.0);
 
	agent->addAction(primAction1);
	agent->addAction(primAction2);
 
	// create the discrete state with the self-coded class
	/* not used
	discState = new CMultiPoleDiscreteState();
	*/
 
	// add the discrete state to the agent's state modifier
	// discState must not be modified (e.g. with a State-Substitution) by now
	agent->addStateModifier(discState);
 
	// Create the learner and the Q-Function
	CFeatureQFunction *qTable = new CFeatureQFunction(agent->getActions(), discState);
	CTDLearner *learner = new CQLearner(rewardFunction, qTable);
	// initialise the learning algorithm parameters
	learner->setAlpha(0.1);
	//learner->getQFunction()->setGamma(0.95);
	learner->getETraces()->setReplacingETraces(true);
	learner->getETraces()->setLambda(0.9);
 
	// add the Q-Learner to the listener list
	agent->addSemiMDPListener(learner);
 
	// Create the learners controller
	CAgentStatisticController *policy = NULL;
	policy = new CQGreedyPolicy(agent->getActions(), qTable);
	// set the policy as controller of the agent
	agent->setController(policy);
	
	// disable automatic logging of the episode from the agent
	agent->setLogEpisode(false);
 
	int steps = 0;
 
	// Learn for 500 Episodes
	for (int i = 0; i < 500 && steps < 100000; i++)
	{
		// Do one training trial, with max 100000 steps
		steps = agent->doControllerEpisode(1, 100000);
 
		printf("Episode %d %s with %d stepsn", i, model->isFailed() ? "failed" : "succeded", steps);
		
	}
 
 
	delete policy;
	delete learner;
	delete agent;
	delete qTable;
	delete model;
	
	printf("nn<< Press Enter >>n");
	getchar();
};

Open in new window

  • Ошибка c2112 киа сид
  • Ошибка c2112 kia sportage
  • Ошибка c2112 kia ceed jd
  • Ошибка c2112 hyundai elantra
  • Ошибка c2106 левый операнд должен быть левосторонним значением