मेरे कार्यक्रम है, जो बिल्कुल वही बात हर बार इसे चलाता (दूरी में एक बिंदु स्प्राइट चलता है) बेतरतीब ढंग से टर्मिनल 'अवैध निर्देश' पर पाठ के साथ असफल हो जायेगी करता है। मेरे गुगल ने लोगों को यह महसूस किया है कि असेंबली लिखते समय यह समझ में आता है क्योंकि असेंबली उन प्रकार की त्रुटियों को फेंकता है।अवैध निर्देश ++ जब सी प्रोग्रामिंग लिनक्स
लेकिन क्यों जी ++ इस तरह एक अवैध अनुदेश पैदा होगा? ऐसा नहीं है कि मैं विंडोज के लिए संकलन कर रहा हूं और फिर लिनक्स पर चल रहा हूं (जो तब तक, जब तक कि दोनों x86 पर हैं, AFAIK को अवैध निर्देश नहीं देना चाहिए)। मैं नीचे मुख्य फाइल पोस्ट करूंगा।
मैं मज़बूती से त्रुटि पुन: पेश नहीं कर सकते। हालांकि, अगर मैं यादृच्छिक परिवर्तन करता हूं (यहां एक जगह जोड़ें, वहां स्थिर रहें) जो एक पुनर्मूल्यांकन को मजबूर करता है, मैं एक बाइनरी प्राप्त कर सकता हूं जो अवैध निर्देश के साथ असफल हो जाता है, जब तक कि मैं ब्रेक पॉइंट सेट करने की कोशिश नहीं करता, जो कि बनाता है अवैध निर्देश 'गायब'। :(
#include <stdio.h>
#include <stdlib.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include <SDL/SDL.h>
#include "Screen.h" //Simple SDL wrapper
#include "Textures.h" //Simple OpenGL texture wrapper
#include "PointSprites.h" //Simple point sprites wrapper
double counter = 0;
/* Here goes our drawing code */
int drawGLScene()
{
/* These are to calculate our fps */
static GLint T0 = 0;
static GLint Frames = 0;
/* Move Left 1.5 Units And Into The Screen 6.0 */
glLoadIdentity();
glTranslatef(0.0f, 0.0f, -6);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
glEnable(GL_POINT_SPRITE_ARB);
glTexEnvi(GL_POINT_SPRITE, GL_COORD_REPLACE, GL_TRUE);
glBegin(GL_POINTS); /* Drawing Using Triangles */
glVertex3d(0.0,0.0, 0);
glVertex3d(1.0,0.0, 0);
glVertex3d(1.0,1.0, counter);
glVertex3d(0.0,1.0, 0);
glEnd(); /* Finished Drawing The Triangle */
/* Move Right 3 Units */
/* Draw it to the screen */
SDL_GL_SwapBuffers();
/* Gather our frames per second */
Frames++;
{
GLint t = SDL_GetTicks();
if (t - T0 >= 50) {
GLfloat seconds = (t - T0)/1000.0;
GLfloat fps = Frames/seconds;
printf("%d frames in %g seconds = %g FPS\n", Frames, seconds, fps);
T0 = t;
Frames = 0;
counter -= .1;
}
}
return 1;
}
GLuint objectID;
int main(int argc, char **argv)
{
Screen screen;
screen.init();
screen.resize(800,600);
LoadBMP("./dist/Debug/GNU-Linux-x86/particle.bmp");
InitPointSprites();
while(true){drawGLScene();}
}
मैं दोषपूर्ण स्मृति मॉड्यूल की जगह सुझाव है। – avakar
मैं दोषपूर्ण टिप्पणी लेखक को बदलने का सुझाव दूंगा। –
जीडीबी के तहत अपना कोड चलाएं और फिर जब आप अपवाद प्राप्त करते हैं तो बैकट्रैक (बीटी) करें। –