ns-3模拟出错?

时间:2016-01-07 20:53:23

标签: c++ ns-3 ndnsim

我正在尝试运行模拟,但我一直遇到某种错误。我不是C ++的专家,但我认为这是由于头文件包含。我收到以下错误:

error: ISO C++ forbids declaration of ‘type name’ with no type [-fpermissive]
 void OutInterest(Ptr<const ns3::ndn::InterestHeader> interestHeader,Ptr<const ns3::ndn::Face> face) {
                            ^
../scratch/vndn_simulation.cc:87:52: error: template argument 1 is invalid
 void OutInterest(Ptr<const ns3::ndn::InterestHeader> interestHeader,Ptr<const ns3::ndn::Face> face) {
                                                    ^
../scratch/vndn_simulation.cc:87:28: error: ISO C++ forbids declaration of ‘type name’ with no type [-fpermissive]
 void OutInterest(Ptr<const ns3::ndn::InterestHeader> interestHeader,Ptr<const ns3::ndn::Face> face) {

有关如何解决此错误的想法吗?

1 个答案:

答案 0 :(得分:1)

它在这里说:

#include<windows.h>
#include <GL/glut.h>
#include<iostream>
#include <stdlib.h>
#include <cmath>
#include <stdio.h>
#include <stdlib.h>

// (...)



GLuint loadBMP_custom(const char * imagepath);
GLuint tex = loadBMP_custom("texture.bmp");



GLuint loadBMP_custom( const char * imagepath )
{

   GLuint texture;

   int width, height;

   unsigned char * data;

   FILE * file;

   file = fopen( imagepath, "rb" );

   if ( file == NULL ) return 0;

   width = 256;
   height = 256;
   data = (unsigned char *)malloc( width * height * 3 );

   fread( data, width * height * 3, 1, file );
   fclose( file );

  for(int i = 0; i < width * height ; ++i)
  {
    int index = i*3;
    unsigned char B,R;
    B = data[index];
    R = data[index+2];

    data[index] = R;
    data[index+2] = B;

  }



  glGenTextures( 1, &texture );
  glBindTexture( GL_TEXTURE_2D, texture );
  glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE,GL_MODULATE );
  glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST );


  glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,GL_LINEAR );
  glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,GL_REPEAT );
  glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,GL_REPEAT );
  gluBuild2DMipmaps( GL_TEXTURE_2D, 3, width, height,GL_RGB, GL_UNSIGNED_BYTE, data );
  free( data );

  return texture;
}



// (...)



void renderScene(void)
{

    glMatrixMode(GL_MODELVIEW);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);


    // Reset transformations
    glLoadIdentity();
    // Set the camera
    gluLookAt(  posX, 1.0f, posZ,
            posX+vlx, posY+vly,  posZ+vlz,
            0.0f, 1.0f,  0.0f);




    // xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

    glBindTexture(GL_TEXTURE_2D, tex);

    glBegin(GL_QUADS);
        glTexCoord2f (0.0, 0.0);
        glVertex3f(-100.0f, -0.02f, -100.0f);
        glTexCoord2f (0.0, 1.0);
        glVertex3f(-100.0f, -0.02f,  100.0f);
        glTexCoord2f (1.0, 1.0);
        glVertex3f( 100.0f, -0.02f,  100.0f);
        glTexCoord2f (1.0, 0.0);
        glVertex3f( 100.0f, -0.02f, -100.0f);
    glEnd();

    // xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx


    // [Also display 3D blocks in space besides the above QUAD, which serves as ground]

    glFlush();
    glutSwapBuffers();

}

//(...)

int main(int argc, char **argv)
{

    // (...)

    glEnable (GL_TEXTURE_2D) ;

    glutMainLoop();
    return 1;
}

您无法转发声明class NameComponents; ^ In file included from ./ns3/ndn-v2v-net-device-face.h:31:0, from ../scratch/vndn_simulation.cc:15: ./ns3/ndn-header-helper.h:34:21: note: ‘ns3::ndn::NameComponents’ has a previous declaration here typedef Name NameComponents; ^ ,因为编译器已经看到它是NameComponents而不是类。