By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,985 Members | 1,776 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,985 IT Pros & Developers. It's quick & easy.

What does there warnings mean ?

P: 12
When compiling i get these warnings and i dont know why. Can anyone please explain ?

Tommy,

1>------ Build started: Project: sdl, Configuration: Release Win32 ------
1>Compiling...
1>Polygonstruct.cpp
1>C:\Program Files\Microsoft Visual Studio 8\VC\include\xlocnum(590) : warning C4312: 'type cast' : conversion from 'uintptr_t' to 'void *' of greater size
1> C:\Program Files\Microsoft Visual Studio 8\VC\include\xlocnum(566) : while compiling class template member function 'std::istreambuf_iterator<_Elem,_Traits> std::num_get<_Elem,_InIt>::do_get(_InIt,_InIt,std: :ios_base &,std::ios_base::iostate &,void *&) const'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _InIt=std::istreambuf_iterator<char,std::char_trai ts<char>>
1> ]
1> C:\Program Files\Microsoft Visual Studio 8\VC\include\xlocnum(1365) : see reference to class template instantiation 'std::num_get<_Elem,_InIt>' being compiled
1> with
1> [
1> _Elem=char,
1> _InIt=std::istreambuf_iterator<char,std::char_trai ts<char>>
1> ]
1>C:\Program Files\Microsoft Visual Studio 8\VC\include\xlocnum(590) : warning C4312: 'type cast' : conversion from 'uintptr_t' to 'void *' of greater size
1> C:\Program Files\Microsoft Visual Studio 8\VC\include\xlocnum(566) : while compiling class template member function 'std::istreambuf_iterator<_Elem,_Traits> std::num_get<_Elem,_InIt>::do_get(_InIt,_InIt,std: :ios_base &,std::ios_base::iostate &,void *&) const'
1> with
1> [
1> _Elem=wchar_t,
1> _Traits=std::char_traits<wchar_t>,
1> _InIt=std::istreambuf_iterator<wchar_t,std::char_t raits<wchar_t>>
1> ]
1> C:\Program Files\Microsoft Visual Studio 8\VC\include\xlocnum(1371) : see reference to class template instantiation 'std::num_get<_Elem,_InIt>' being compiled
1> with
1> [
1> _Elem=wchar_t,
1> _InIt=std::istreambuf_iterator<wchar_t,std::char_t raits<wchar_t>>
1> ]
1>Build log was saved at "file://e:\c++\sdl\sdl\Release\BuildLog.htm"
1>sdl - 0 error(s), 2 warning(s)
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

Here are the code :

Expand|Select|Wrap|Line Numbers
  1. /*
  2.  
  3. Homemade class for loading .ase object files and put vertex and face data into datastructure
  4. Does not support lights, but have made a colorchage on each face to get a "false" feeling of
  5. volume of the objects, this means that the setColor is not active for objects until lights are
  6. supported. Anyhow this colorchange function is not so robust when the objects have over 100 faces
  7. because then the step between ecah color are getting to small.
  8.  
  9. */
  10.  
  11.  
  12. //#include "Polygonstruct.h"
  13. #include "SDL.h"         // SDL: window & input library
  14. #include "SDL_opengl.h"  // platform independent OpenGL include
  15. #include <vector>
  16. #include <iostream>
  17. #include <fstream>
  18. #include <string>
  19. #include <math.h>
  20. #include <stdio.h>
  21. #include <stdlib.h> 
  22. using namespace std;
  23.  
  24. //struct to store vertices
  25. struct VERTEX{
  26.     float x,y,z;
  27. };
  28.  
  29.  
  30. //struct to store faces
  31.  
  32. struct FACE{
  33.     int index[3];
  34. };
  35.  
  36.  
  37. class Poly{
  38. public:
  39.  
  40.     //vector isnt the fastest structure but uses them anyway
  41.  
  42.     vector <VERTEX> vertices;
  43.     vector <FACE> faces;
  44.  
  45.     VERTEX v;
  46.     FACE    f;
  47.  
  48.     float xPos;
  49.     float yPos;
  50.     float zPos;
  51.  
  52.     GLfloat maxvalue;
  53.     int        numberOfVertices;
  54.     int        numberOfFaces;
  55.     string filename;
  56.  
  57. public:
  58.  
  59.     Poly(string s){
  60.  
  61.     LoadFile(s);    
  62.     }     
  63.  
  64. //set pos in world
  65.     void setPos(float x,float y, float z){
  66.         xPos=x;
  67.         yPos=y;
  68.         zPos=z;
  69.     }
  70.  
  71.     float getPosX(){
  72.         return xPos;
  73.     }
  74.  
  75.     float getPosY(){
  76.         return yPos;
  77.     }
  78.  
  79.     float getPosZ(){
  80.         return zPos;
  81.     }
  82.  
  83.  
  84.         void LoadFile(string s){
  85.  
  86.         string line;
  87.  
  88.         const char* filename = s.c_str();        //convert str to char and return pointer
  89.  
  90.         ifstream In(filename);
  91.         if (!In) {
  92.         cerr << "Unable to open file";
  93.         exit(1);   // call system to stop
  94.         }
  95.  
  96.         //Parse .asj file to extract relevant data
  97.  
  98.         while(!In.eof()){
  99.  
  100.         In>>line;
  101.  
  102.         //number of vertices
  103.         if (line=="*MESH_NUMVERTEX"){
  104.             In>>line;
  105.             const char* templine = line.c_str();
  106.             numberOfVertices = atoi(templine);
  107.         }
  108.         //number of faces
  109.         if (line=="*MESH_NUMFACES"){
  110.             In>>line;
  111.             const char* templine = line.c_str();
  112.             numberOfFaces = atoi(templine);
  113.         }
  114.         //extract index and vertices
  115.         if(line=="*MESH_VERTEX"){
  116.  
  117.             In>>line>>(float)v.x>>(float)v.y>>(float)v.z;
  118.             //cout<<i.nVertex<<"   "<<v.x<<"   "<<v.y<<"   "<<v.z<<endl;
  119.  
  120.             // get max abs vertex value 1 step in normalizing vertex data
  121.  
  122.             if ( fabs(v.x)>maxvalue){
  123.                 maxvalue=fabs(v.x);
  124.             }
  125.             if ( fabs(v.y)>maxvalue){
  126.                 maxvalue=fabs(v.y);
  127.             }
  128.             if ( fabs(v.z)>maxvalue){
  129.                 maxvalue=fabs(v.z);
  130.             }
  131.  
  132.  
  133.             vertices.push_back(v);
  134.  
  135.  
  136.         }
  137.         //cout<<maxvalue<<endl;
  138.  
  139.         //extract faces
  140.         if(line=="*MESH_FACE"){
  141.         In>>line>>line>>(int)f.index[0]>>line>>(int)f.index[1]>>line>>(int)f.index[2];
  142.         faces.push_back(f);
  143.         }
  144.  
  145.  
  146.         }//while
  147.  
  148.         In.close();
  149.         //cout<<faces[0].index[0]<<"    "<<faces[0].index[1]<<"   "<<faces[0].index[2];
  150.         normalizeVertices();
  151.  
  152.     }
  153.  
  154. void Draw(){
  155.  
  156. float inc = (float)0.5/(float)numberOfVertices; // Have to do some color changes to make a "feeling" of light
  157.  
  158. //glPushMatrix();
  159.     GLfloat color = 0.5f;
  160.     glBegin(GL_TRIANGLES);
  161.     for(int i=0; i<numberOfFaces; i++){
  162.         glColor3f(color,0.0,0.0);
  163.             color=color+inc;
  164.         for(int j=0; j<3; j++){
  165.  
  166.             //cout<<vertices[faces[i].index[j]].x<<"   "<<vertices[faces[i].index[j]].y<<"   "<<vertices[faces[i].index[j]].z<<endl;
  167.             glVertex3f(vertices[faces[i].index[j]].x,vertices[faces[i].index[j]].y,vertices[faces[i].index[j]].z);
  168.         }
  169.     }
  170.     glEnd();
  171. //glPopMatrix();
  172.  
  173. }
  174.  
  175.  
  176. // When importing 3d objects vertex data ranges can be wide. this function normalize vertex data
  177. // to fall into the range -1 to 1 for x,y and z coord.
  178.  
  179. void normalizeVertices(){
  180.  
  181.     for (unsigned int c=0;c<vertices.size();c++)
  182.     {
  183.         vertices[c].x=(vertices[c].x)/maxvalue;
  184.         vertices[c].y=(vertices[c].y)/maxvalue;
  185.         vertices[c].z=(vertices[c].z)/maxvalue;
  186.         //cout<<vertices[c].x<<"  "<<vertices[c].y<<"  "<<vertices[c].z<<endl;
  187.     }
  188.  
  189.  
  190. }
  191.  
  192. };
Sep 18 '06 #1
Share this Question
Share on Google+
2 Replies


Banfa
Expert Mod 5K+
P: 8,916
It would appear that you are using the /Wp64 compiler switch to detect 64bit compatability issues and 1 such issue is

int i = <somememoryAddress>;
void *p = (void *)i;

This is an issue because on 64 bit windows int is 32 bits and void * is 64 bits. The int can be sign extended resulting in the pointer p pointing to the wrong place. Solve it by either removing the compiler switch or if that is not an option using type __int64 for integers holding memory addresses.
Sep 18 '06 #2

P: 12
Damn! its fantastic, turned off detect 64 bit comp and no more strange errors!
You really impress me. Thanx a lot !

Tommy,


It would appear that you are using the /Wp64 compiler switch to detect 64bit compatability issues and 1 such issue is

int i = <somememoryAddress>;
void *p = (void *)i;

This is an issue because on 64 bit windows int is 32 bits and void * is 64 bits. The int can be sign extended resulting in the pointer p pointing to the wrong place. Solve it by either removing the compiler switch or if that is not an option using type __int64 for integers holding memory addresses.
Sep 19 '06 #3

Post your reply

Sign in to post your reply or Sign up for a free account.