943,929 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 2859
  • C++ RSS
Dec 31st, 2008
0

error in cstdlib

Expand Post »
hello again,
just tried to compile my project and i'm getting errors with a file cstdlib

Error 2 error C2039: 'abort' : is not a member of '`global namespace'' c:\program files\microsoft visual studio 9.0\vc\include\cstdlib 23
Error 3 error C2873: 'abort' : symbol cannot be used in a using-declaration c:\program files\microsoft visual studio 9.0\vc\include\cstdlib 23
Error 4 error C2039: 'exit' : is not a member of '`global namespace'' c:\program files\microsoft visual studio 9.0\vc\include\cstdlib 26
Error 5 error C2873: 'exit' : symbol cannot be used in a using-declaration c:\program files\microsoft visual studio 9.0\vc\include\cstdlib 26

i have no idea whats causing these errors so far as i'm aware i'm not even using cstdlib

-Midi
Similar Threads
Reputation Points: 34
Solved Threads: 4
Light Poster
midimatt is offline Offline
49 posts
since Mar 2008
Dec 31st, 2008
0

Re: error in cstdlib

try
c++ Syntax (Toggle Plain Text)
  1.  
  2. #include <iostream>
  3.  
  4. //...or
  5.  
  6. using namespace std;
  7.  
  8. //...
Reputation Points: 47
Solved Threads: 69
Posting Whiz
cikara21 is offline Offline
340 posts
since Jul 2008
Dec 31st, 2008
0

Re: error in cstdlib

all the files that seem to give me the cstdlib error have that in them already

-midi
Reputation Points: 34
Solved Threads: 4
Light Poster
midimatt is offline Offline
49 posts
since Mar 2008
Dec 31st, 2008
0

Re: error in cstdlib

post header files...please...
Reputation Points: 47
Solved Threads: 69
Posting Whiz
cikara21 is offline Offline
340 posts
since Jul 2008
Dec 31st, 2008
0

Re: error in cstdlib

Of more relevance, try posting a small sample of your code that illustrates the problem. Also provide information about your compiler settings (eg any settings you've tweaked in the VC IDE to non-standard settings).

My guess is that you've been playing with some #define's somewhere (either before you've include'd some headers, or in the IDE settings) and they interact with the headers in strange ways.
Reputation Points: 193
Solved Threads: 32
Posting Whiz in Training
grumpier is offline Offline
206 posts
since Aug 2008
Dec 31st, 2008
0

Re: error in cstdlib

the only thing i've done is add

GLUT_BUILDING_LIB to the preprocessors to stop a clash between glut and stdlib

i have no idea what code to post, my program consists of 30 files and the error says its in the file cstdlib the only thing i have to go on is the errors happen after these 3 files

test.cpp
c++ Syntax (Toggle Plain Text)
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. #include "vrobject.h"
  6.  
  7.  
  8. int main(int argc, char **argv){
  9.  
  10. Viewer *myViewer=new Viewer;
  11. myViewer->Init(argc,argv);
  12. myViewer->InitWorld();
  13. myViewer->SetValue(BUFFER,MDOUBLE);
  14. myViewer->CreateWin("Test",1280,720);
  15. myViewer->InitCamera();
  16. myViewer->Show();
  17.  
  18. return 0;
  19. }
viewer.cpp
c++ Syntax (Toggle Plain Text)
  1. #include "viewer.h"
  2.  
  3. using namespace std;
  4.  
  5. Viewer::Viewer(){
  6.  
  7.  
  8. WinName="";
  9. BufType=GLUT_SINGLE;
  10.  
  11. for(int i=0;i<3;i++){
  12. background[i]=0.0f;
  13. }
  14.  
  15. }
  16.  
  17. Viewer::~Viewer(){
  18. return;
  19. }
  20.  
  21. void Viewer::Init(int argc,char **argv){
  22.  
  23. eye[0]=0.0f;
  24. eye[1]=0.5;
  25. eye[2]=25.0;
  26.  
  27. aim[0]=0.0f;
  28. aim[1]=0.0f;
  29. aim[2]=0.0f;
  30.  
  31. upright[0]=0.0f;
  32. upright[1]=1.0f;
  33. upright[2]=0.0f;
  34.  
  35. glutInit(&argc,argv);
  36.  
  37. }
  38.  
  39. void Viewer::CreateWin(char *Name,int Width,int Height){
  40. WinName=Name;
  41. WinWidth=Width;
  42. WinHeight=Height;
  43. }
  44.  
  45. void Viewer::SetValue(myEnum PName,myEnum Type){
  46.  
  47. switch(PName){
  48. case BUFFER:
  49. if(Type==MDOUBLE)
  50. BufType=GLUT_DOUBLE;
  51. else
  52. if(Type==SINGLE)
  53. BufType=GLUT_SINGLE;
  54. break;
  55. case BACKCOLOUR:
  56. break;
  57. default:
  58. break;
  59. }
  60. }
  61.  
  62.  
  63. void Viewer::InitWorld(){
  64. vrman=new WorldManager;
  65. vrman->initialise();
  66.  
  67. }
  68. void Viewer::InitCamera(){
  69. mycamera=new camera(PERSPECTIVE);
  70. mycamera->SetValue(MNEAR,1.0f);
  71. mycamera->SetValue(YANGLE,45.0f);
  72.  
  73.  
  74. mycamera->SetValuev(AIMAT, aim);
  75. mycamera->SetValuev(UPDIRECTION, upright);
  76. mycamera->SetValuev(POSITION, eye);
  77.  
  78. mycamera->SetValue(MFAR,500.0f);
  79. mycamera->SetValue(HEIGHT,WinHeight);
  80. mycamera->SetValue(ASPECT,1.0f);
  81. }
  82.  
  83. void Viewer::SetCamera(float nvalue,float viewangle){
  84. mycamera->SetValue(MNEAR, nvalue);
  85. mycamera->SetValue(YANGLE, viewangle);
  86.  
  87. }
  88.  
  89. void Viewer::Show(){
  90.  
  91. GLInit();
  92. glutMainLoop();
  93.  
  94. }
  95.  
  96.  
  97. void Viewer::GLInit(){
  98. glutInitDisplayMode(BufType |GLUT_RGB |GLUT_DEPTH);
  99. glutInitWindowSize(WinWidth, WinHeight);
  100. glutCreateWindow(WinName);
  101. glutReshapeFunc(Reshape);
  102. glutDisplayFunc(Display);
  103. glutMouseFunc(Mouse);
  104. glutIdleFunc(Idle);
  105. glutKeyboardFunc(Keyboard);
  106. glutSpecialFunc(SpecialKey);
  107. glEnable(GL_DEPTH_TEST);
  108. glClearColor(0.0f,0.0f,0.0f,1.0f);
  109.  
  110. }
  111.  
  112.  
  113. void Viewer::Display(){
  114. glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  115.  
  116. vrman->exec_loop();
  117.  
  118.  
  119. glFlush();
  120. if(BufType==GLUT_DOUBLE){
  121.  
  122. glutSwapBuffers();
  123. }
  124.  
  125.  
  126. }
  127.  
  128. void Viewer::Reshape(int w,int h){
  129.  
  130. glViewport(0,0,(GLsizei)w,(GLsizei)h);
  131. WinWidth=w;
  132. WinHeight=h;
  133. mycamera->SetValuev(POSITION,eye);
  134. mycamera->SetValuev(AIMAT,aim);
  135. mycamera->Render();
  136.  
  137. }
  138.  
  139. void Viewer::Mouse(int button,int state,int x,int y){
  140.  
  141. vrman->mouse(button,state,x,y);
  142. Display();
  143. }
  144.  
  145. void Viewer::Idle(){
  146. vrman->idle();
  147. Display();
  148. }
  149.  
  150. void Viewer::Keyboard(unsigned char key,int x,int y){
  151.  
  152. switch(key){
  153. case 0x14b:
  154. case 38://up
  155. eye[2]-=0.5;
  156. aim[2]-=0.5;
  157. break;
  158. case 40: //down arrow
  159. eye[2]+=0.5;
  160. aim[2]+=0.5;
  161. break;
  162. case 37://left
  163. eye[0]-=0.5;
  164. aim[0]-=0.5;
  165. break;
  166. case 39://right arrow
  167. eye[0]+=0.5;
  168. aim[0]+=0.5;
  169. break;
  170. default:
  171. vrman->keyboard((unsigned char)key,x,y);
  172. break;
  173. }
  174.  
  175. Display();
  176. }
  177.  
  178. void Viewer::SpecialKey(int key, int x, int y){
  179. switch(key){
  180. case GLUT_KEY_F1:
  181. upright[0]=0.0f;
  182. upright[1]=0.0f;
  183. upright[2]=-1.0f;
  184. aim[0]=0.0f;
  185. aim[1]=0.0f;
  186. aim[2]=0.0f;
  187. eye[0]=0.0f;
  188. eye[1]=25.0f;
  189. eye[2]=0.0f;
  190. break;
  191. case GLUT_KEY_F2:
  192. upright[0]=0.0f;
  193. upright[1]=1.0f;
  194. upright[2]=0.0f;
  195. aim[0]=0.0f;
  196. aim[1]=0.0f;
  197. aim[2]=0.0f;
  198. eye[0]=0.0f;
  199. eye[1]=0.5f;
  200. eye[2]=25.0f;
  201. break;
  202. case GLUT_KEY_F12:
  203. vrman->restart();
  204. break;
  205. case GLUT_KEY_UP:
  206. eye[2]-=0.5;
  207. aim[2]-=0.5;
  208. break;
  209. case GLUT_KEY_DOWN:
  210. eye[2]+=0.5;
  211. aim[2]+=0.5;
  212. break;
  213. case GLUT_KEY_LEFT:
  214. eye[0]-=0.5;
  215. aim[0]-=0.5;
  216. break;
  217. case GLUT_KEY_RIGHT:
  218. eye[0]+=0.5;
  219. aim[0]+=0.5;
  220. break;
  221. case GLUT_KEY_PAGE_UP:
  222. eye[1]+=0.5;
  223. aim[1]+=0.5;
  224. break;
  225. case GLUT_KEY_PAGE_DOWN:
  226. eye[1]-=0.5;
  227. aim[1]-=0.5;
  228. break;
  229. default:
  230. vrman->keyboard((unsigned char)key,x,y);
  231. break;
  232. }
  233. mycamera->SetValuev(UPDIRECTION,upright);
  234. mycamera->SetValuev(POSITION,eye);
  235. mycamera->SetValuev(AIMAT,aim);
  236. mycamera->Render();
  237. Display();
  238. }
worldmanager.cpp
c++ Syntax (Toggle Plain Text)
  1. #include "worldmanager.h"
  2.  
  3. using namespace std;
  4.  
  5. void WorldManager::initialise(){
  6. myscene=new Scene;
  7. myscene->initialise();
  8. return;
  9. }
  10.  
  11. void WorldManager::restart(){
  12.  
  13.  
  14. }
  15.  
  16. void WorldManager::exec_loop(){
  17. //exectuion loop.
  18. render();
  19. }
  20.  
  21. void WorldManager::render(){
  22.  
  23. // Draw a scene
  24. myscene->render();
  25. }
  26.  
  27. void WorldManager::keyboard(unsigned char key,int x,int y)
  28. {
  29. myscene->keyboard(key,x,y);
  30. }
  31.  
  32. void WorldManager::mouse(int button, int state, int x,int y){
  33. return;
  34. }
  35.  
  36. void WorldManager::idle(){
  37. return;
  38. }

i'm thinking it could be a corrupt header file but i cant seem to find stdlib anywhere atleast not one that looks anything like what i have at the moment

-midi
Last edited by midimatt; Dec 31st, 2008 at 11:37 pm.
Reputation Points: 34
Solved Threads: 4
Light Poster
midimatt is offline Offline
49 posts
since Mar 2008
Jan 1st, 2009
0

Re: error in cstdlib

I'd look in the glut header files before looking in the cstdlib. The fact there is even a macro GLUT_BUILDING_LIB to define to "stop a clash between glut and stdlib" says that the incompatibility is the glut header file and library, rather than the standard library.

Generally, suppliers of third-party libraries (like glut) are responsible for ensuring compatibility with compilers and standard libraries. Presumably, in your case, the glut library people have not ensured compatibility with your version of Visual Studio.
Reputation Points: 193
Solved Threads: 32
Posting Whiz in Training
grumpier is offline Offline
206 posts
since Aug 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Win version for atomic.h
Next Thread in C++ Forum Timeline: Creating strong AI (open source)





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC