I am having trouble with a struct in my code called 'camera' (using VC++ 2010 express)
Camera.h:
[code]
#pragma once
#include "renderStructs.h"
struct camera
{
public:
point pos;
pointi rotation;
int fov;
camera(point Pos, pointi Rotation, int Fov);
~camera();
camera();
};
[/code]
Camera.cpp:
[code]
#include "camera.h"
camera::camera(point Pos, pointi Rotation, int Fov) : pos(Pos), rotation(Rotation), fov(Fov)
{
}
camera::camera()
{
}
camera::~camera()
{
}
[/code]
point and pointi are structs in renderStructs.h that compile without errors.
I am also having issues with gl.h. I think the two errors might be related considering where i include gl.h eventually leads back to an include "camera.h" line.
Errors for camera:
c:\users\david\desktop\dropbox\**********\include\camera.h(7): error C2236: unexpected 'struct' 'camera'. Did you forget a ';'?
1>c:\users\david\desktop\dropbox\***********\include\camera.h(7): error C2143: syntax error : missing ';' before '{'
1>c:\users\david\desktop\dropbox\**********\include\camera.h(7): error C2447: '{' : missing function header (old-style formal list?)
They all refer to this line:
struct camera
-> {
public:
The opengl errors are the long list of errors you typically get when you forget to include <windows.h> starting with:
c:\program files\microsoft sdks\windows\v7.0a\include\gl\gl.h(1152): error C2144: syntax error : 'void' should be preceded by ';'
1>c:\program files\microsoft sdks\windows\v7.0a\include\gl\gl.h(1152): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files\microsoft sdks\windows\v7.0a\include\gl\gl.h(1152): error C2146: syntax error : missing ';' before identifier 'glAccum'
1>c:\program files\microsoft sdks\windows\v7.0a\include\gl\gl.h(1152): error C2182: 'APIENTRY' : illegal use of type 'void'
And exceeding 100 errors.
I am also having trouble with class entity:
entity.h:
[code]
#pragma once
#include "renderData.h"
class entity
{
public:
virtual renderData *outputRenderData() {};
entity();
~entity();
}
[/code]
entity.cpp:
[code]
#include "entity.h"
entity::entity()
{
}
entity::~entity()
{
}
[/code]
Entity error:
c:\users\david\desktop\dropbox\********\entity.cpp(6): error C2533: 'entity::{ctor}' : constructors not allowed a return type
The error points to the constructor in entity.cpp
I have tried deleting IPCH and the .sdf and recompiling but no luck there.
When I include gl.h I do so as such:
#include "error.h" //this file eventully leads to an #include <windows.h> line
#include "glew.h"
#include <gl\GL.h>
I've also tried:
#include "error.h"
#include "glew.h"
#include <Windows.h>
#include <gl\GL.h>
Neither way seems to work.
Thanks ahead of time! :)
Requested renderStructs code:
.h:
[code]
#pragma once
//just two simple structs
struct point {float x, y, z; point(float c1, float c2, float c3); point();}; //a vertex struct with points x y and z
struct face {point p1, p2, p3;}; //a face struct using the vertex struct
struct pointi {int x, y, z; pointi(int c1, int c2, int c3); pointi();}; //a vertex struct with points x y and z
[/code]
.cpp:
[code]
#include "renderStructs.h"
point::point(float c1, float c2, float c3) : x(c1), y(c2), z(c3)
{
this->x = c1;
this->y = c2;
this->z = c3;
}
point::point()
{
}
pointi::pointi(int c1, int c2, int c3) : x(c1), y(c2), z(c3)
{
}
pointi::pointi()
{
}
[/code]
Show us the code for renderStructs.h, also, wrap your code in [cpp] tags.
Bro you should post in [url=http://www.facepunch.com/threads/1152030]WDYNHW[/url], you'll get more help there ;)
Also, when you post code, it's a lot more readable in [noparse][code]code here[/code][/noparse] tags.
[QUOTE=flayne;34016271]
entity.h:
[code]
#pragma once
#include "renderData.h"
class entity
{
public:
virtual renderData *outputRenderData() {};
entity();
~entity();
}
[/code][/QUOTE]
You're missing a semicolon on the last line here.
[QUOTE=flayne;34016271]
[code]
#include "renderStructs.h"
point::point(float c1, float c2, float c3) : x(c1), y(c2), z(c3)
{
this->x = c1;
this->y = c2;
this->z = c3;
}
point::point()
{
}
pointi::pointi(int c1, int c2, int c3) : x(c1), y(c2), z(c3)
{
}
pointi::pointi()
{
}
[/code][/QUOTE]
The "this->x/y/z = c1/c2/c3" isn't necessary here, since you do it in the initializer list.
You're also using structs for things you should be using classes for.
[QUOTE=dajoh;34016631]You're missing a semicolon on the last line here.
The "this->x/y/z = c1/c2/c3" isn't necessary here, since you do it in the initializer list.
You're also using structs for things you should be using classes for.[/QUOTE]
Unless i'm incorrect, structs and classes are exactly the same except with a different default permissions (public for struct, private for class)
DERP! I feel like an idiot thank you so much. also Icedshot is correct struct = class with default public permissions where class = struct with default protected (it might actually be private) permisssions
Default permission for a class is private, not protected.
You should check out the Facepunch Programmers chat room on Steam, if you run into any more problems we should be able to help you quickly. It's also a nice place in general.
[QUOTE=dajoh;34017232]Default permission for a class is private, not protected.
You should check out the Facepunch Programmers chat room on Steam, if you run into any more problems we should be able to help you quickly. It's also a nice place in general.[/QUOTE]
Thanks for the recommendation ... because I'm still getting OpenGL issues, I'll be on there shortly
[editline]2nd January 2012[/editline]
[QUOTE=dajoh;34017232]Default permission for a class is private, not protected.
You should check out the Facepunch Programmers chat room on Steam, if you run into any more problems we should be able to help you quickly. It's also a nice place in general.[/QUOTE]
Can you give me a link to that please?
Nevermind found it
[QUOTE=dajoh;34017232]Default permission for a class is private, not protected.
You should check out the Facepunch Programmers chat room on Steam, if you run into any more problems we should be able to help you quickly. It's also a nice place in general.[/QUOTE]
In that case, i am slightly confused as to why you say he should be using classes rather than structs. Surely they are practical identical?
[QUOTE=Icedshot;34018525]In that case, i am slightly confused as to why you say he should be using classes rather than structs. Surely they are practical identical?[/QUOTE]
He's using structs like classes, for example in camera.h he declares the camera struct, and then sets the access to public, when it already is public.
Also, you generally don't use structs for things that contain methods (even though there is nothing wrong with doing so).
[QUOTE=dajoh;34018641]He's using structs like classes, for example in camera.h he declares the camera struct, and then sets the access to public, when it already is public.
Also, you generally don't use structs for things that contain methods (even though there is nothing wrong with doing so).[/QUOTE]
I only declared it public to make sure that wasn't the bug
While it's true you can use structs and classes for the same thing, the general convention is to use structs for POD types, and use classes for everything else.
Sorry, you need to Log In to post a reply to this thread.