C++ (по-видимому) Случайные ошибки компилятораC++

Программы на C++. Форум разработчиков
Anonymous
 C++ (по-видимому) Случайные ошибки компилятора

Сообщение Anonymous »

Я экспериментировал с C, C++ и Allegro благодаря небольшой книге и книге побольше, которые я нашел в книжном магазине Oxfam.
На данный момент я понимаю это довольно хорошо, но я врезался в стену... Всякий раз, когда я компилирую, я получаю следующие ошибки:

Код: Выделить всё

archiboldian@archiboldian:~/Documents/C++ Projects/particles$ g++ particles.c -lalleg -lnoise -o particles
particles.c:19: error: array bound is not an integer constant before ‘]’ token
particles.c:20: error: ‘Vector2D’ does not name a type
particles.c:21: error: ‘Vector2D’ does not name a type
particles.c: In function ‘int main()’:
particles.c:26: error: ‘nPos’ was not declared in this scope
particles.c:28: error: ‘nVel’ was not declared in this scope
particles.c:29: error: ‘nvel’ was not declared in this scope
particles.c:31: error: ‘addParticle’ was not declared in this scope
particles.c: At global scope:
particles.c:47: error: ‘Vector2D’ has not been declared
particles.c:47: error: ‘Color’ has not been declared
particles.c: In function ‘void addParticle(int, int, Vector2d, int, int, int)’:
particles.c:50: error: ‘particles’ was not declared in this scope
А это мой код...

Код: Выделить всё

#include "allegro.h"

struct Vector2d{
double x;
double y;
};

struct Particle {
Vector2d Pos;
Vector2d Vel;
int age;
int LifeSpan;
int colour;
int size;
};

int max = 50;
int pcount = 0;
Particle particles[max];

int main(void) {

Vector2D nPos;
Vector2D nVel;

nPos.x = 320;
nPos.y = 240;
nVel.x = 2;
nvel.y = 0;

addParticle(10, nPos, nVel, 20, makecol(255,255,255), 2);

allegro_init();
install_keyboard();

set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0);

while(!key[KEY_ESC]) {
for(int i=0;i
}
}

allegro_exit();
}

void addParticle(int addp, Vector2D Pos, Vector2d Vel, int LifeSpan, Color colour, int size) {
for(int i=0;i

Подробнее здесь: [url]https://stackoverflow.com/questions/8156127/c-seemingly-random-compiler-errors[/url]

Вернуться в «C++»