So I've got a project, called pong with these files.
main.cpp
include.h
version.h
otlv4.h
i compile it and it works perfect.
but when i add these two files
keyinput.cpp
keyinput.h
iostream disapears!
here is whats in the files causing the problem.Code:C:\Users\Adam\Projects\Pong\include.h|12|error: iostream: No such file or directory| C:\Users\Adam\Projects\Pong\include.h|13|error: sstream: No such file or directory| C:\Users\Adam\Projects\Pong\include.h|14|error: fstream: No such file or directory| C:\Users\Adam\Projects\Pong\otlv4.h|978|error: new: No such file or directory| C:\Users\Adam\Projects\Pong\otlv4.h|1071|error: exception: No such file or directory| C:\Users\Adam\Projects\Pong\otlv4.h||In function 'otl_uncaught_exception':| C:\Users\Adam\Projects\Pong\otlv4.h|1075|error: 'std' undeclared (first use in this function)| C:\Users\Adam\Projects\Pong\otlv4.h|1075|error: (Each undeclared identifier is reported only once| ... the errors go on!
header
sourceCode:#ifndef KEYINPUT_CLASS_BY_ADAM #define KEYINPUT_CLASS_BY_ADAM #include "include.h" #define KEYPRESSED 0x1 // If key is pressed #define KEYNEW 0x2 // If keypress is new #define KEYREPEAT 0x4 // If an operating system repeat event is fired using namespace std; class KeyInput { public: KeyInput(); ~KeyInput(); void keydown(ALLEGRO_KEYBOARD_EVENT *kb); // If a key is released, mark it as unpressed // But if it was not yet processed, leave the keynew flag void keyup(ALLEGRO_KEYBOARD_EVENT *kb); // If an operating system repeat event comes in, set the flag void keyrepeat(ALLEGRO_KEYBOARD_EVENT *kb); // Called once per frame: removes the KEYNEW and KEYREPEAT status from all keys void keyupdate(); // Empties the key buffer void keyclear(); private: char key[256]; }; #endif
and here is include.h incase your curious.Code:#include "KeyInput.h" using namespace std; void KeyInput::keydown(ALLEGRO_KEYBOARD_EVENT *kb) { //what to do when a button was pressed key[kb->keycode] = KEYPRESSED | KEYNEW; } // If a key is released, mark it as unpressed // But if it was not yet processed, leave the keynew flag void KeyInput::keyup(ALLEGRO_KEYBOARD_EVENT *kb) { //what to do when a key is released key[kb->keycode] &= ~KEYPRESSED; } // If an operating system repeat event comes in, set the flag void KeyInput::keyrepeat(ALLEGRO_KEYBOARD_EVENT *kb) { //what to do when a key is held down key[kb->keycode] |= KEYREPEAT; } // Called once per frame: removes the KEYNEW and KEYREPEAT status from all keys void KeyInput::keyupdate() { //reset all the data int i; static int val = ((KEYNEW | KEYREPEAT) << 24) | ((KEYNEW | KEYREPEAT) << 16) | ((KEYNEW | KEYREPEAT) << 8) | KEYNEW | KEYREPEAT; for(i=0; i<64; i++) ((int*)key)[i] &= ~val; } // Empties the key buffer void KeyInput::keyclear() { memset(key, 0, sizeof(*key)*256); }
ive got no clue whats going on...Code:#ifndef INCLUDE_H_ #define INCLUDE_H_ #include <allegro5/allegro5.h> #include <allegro5/a5_iio.h> #include <allegro5/a5_font.h> #include <allegro5/a5_ttf.h> #include <allegro5/a5_primitives.h> #include <allegro5/acodec.h> #include <time.h> #include <stdlib.h> #include <iostream> #include <sstream> #include <fstream> #include "otlv4.h" #endif
EDIT:: for some reason changing KeyInput.cpp and .h to input.h and .cpp makes it work...



LinkBack URL
About LinkBacks


