Thread: VC++ 6.0 to .net problems

  1. #1
    Registered User
    Join Date
    Feb 2006
    Posts
    10

    VC++ 6.0 to .net problems

    Hi, I have an application perfectly running on VC++ 6.0 and then if I open it and make a conversion to VC++ 7.1, I get some bizare errors. It might be the way I configure my .net, but I put all the same options that I used in C++ 6.0

    error C2226: syntax error : unexpected type 'Uint32'
    error C2334: unexpected token(s) preceding ':'; skipping apparent function body

    My code is :

    Code:
    #include "Gob_types.h"
    #include <stdio.h>
    #include <fstream>
    #include <memory.h>
    
    .
    .
    .
    
    
    struct FILEBUF
    {
    	Uint32	m_Taille, m_Pos;
    	Uint8*	m_Buffer;
    
    	FILEBUF()
    		: m_Taille(0), m_Pos(0), m_Buffer(NULL) 
    	{
    	}
    
    	FILEBUF(Uint32 Taille, ifstream & F)
    		: m_Taille(Taille), m_Pos(0), m_Buffer(NULL) 
    	{
    		if (Taille)
    		{
    			m_Buffer = new Uint8 [Taille];
    			memset(m_Buffer,0,Taille);
    			F.read(m_Buffer,Taille);
    		}
    	}
    .
    .
    .
    }
    The funny thing about this is that the error showing is on the line FILEBUF(Uint32 Taille, basic_ifstream & F) and not on the first time I use it : Uint32 m_Taille, m_Pos;

    in Gob_types.h I have
    Code:
    .
    .
    .
    #ifndef _SDL_types_h
    	typedef unsigned char	Uint8;
    	typedef signed char		Sint8;
    	typedef unsigned short	Uint16;
    	typedef signed short	Sint16;
    	typedef unsigned int	Uint32;
    	typedef signed int		Sint32;
    .
    .
    .
    Is it Visual 7.1 that I put a bad configuration, a code problem?

    By the way, if I remove the construction FILEBUF(Uint32 Taille, basic_ifstream & F)
    : m_Taille(Taille), m_Pos(0), m_Buffer(NULL)

    I get an C1001 internal compilor error!!

    Thanx for the help
    Last edited by bibiteinfo; 02-01-2006 at 07:11 AM.

  2. #2
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    Did you specify the std namespace for ifstream? It should be std::ifstream.

  3. #3
    Registered User
    Join Date
    Feb 2006
    Posts
    10
    thanx I think that for this error it was that, because I comment my code and I just get the C1001 error.

    Anyone has a clue where to search when getting this error?? I read in other post to search in the .h files for a } or ; missing, I didn't find... could it be something else?

  4. #4
    Registered User
    Join Date
    Mar 2002
    Posts
    203
    search msdn?

  5. #5
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    The internal compiler error is often caused by a simple syntax mistake. Post the code that gives that error.

  6. #6
    Registered User
    Join Date
    Feb 2006
    Posts
    10
    Code:
    #ifndef MATERIAL_H
    #define MATERIAL_H
    
    #include "HString.h"
    #include <GL/glut.h>
    #include "Lumiere.h"
    #include "Tableau.h"
    #include "HashTable.h"
    #include "Liste.h"
    
    #include "Gob_types.h"
    
    
    //Types de matériaux
    #define MATTYPE_MONO			(0)
    #define MATTYPE_MULTI			(1)
    
    // Transparency types
    #define TRANSP_UNDEFINED		(3)
    #define TRANSP_SUBSTRACTIVE    	(0)
    #define TRANSP_ADDITIVE     	(1)
    #define TRANSP_FILTER     		(2)
    
    
    struct RefMateriau
    {
    	Uint32		m_type;
    	void*		m_Mat;
    
    	RefMateriau()
    		: m_type(0), m_Mat(NULL) {}
    };
    
    
    class Texture
    {
    	friend class MonoMateriau;
    
    private:
    	GLenum	m_Type;
    	GLint	m_NbComp;
    	GLuint	m_Height,m_Width,m_ID;
    
    	GLubyte* m_Texels;
    
    public:
    	Texture(const Texture & Tex);
    	Texture(const char * File, Boolean GenID);
    	Texture(const char * File, GLenum Type, Boolean GenID);
    	Texture(const char * ColorFile, const char * AlphaFile, Boolean ConvertToLuminance, Boolean GenID);
    	Texture(GLubyte *Texels,GLuint Height, GLuint Width, GLenum Type, Boolean CopyTexels, Boolean GenID);
    
    .
    .
    .
    .
    In those lines it's the RefMateriau() : m_type(0), m_Mat(NULL) {} that is call to be wrong.

    If I comment the RefMariau() code, it's just the Texture constructor that is crashing. If I comment the first texture constructur, it's the next that is crashing, and so on... I've comment so much lines that I've corrupt my VS Files ... so I reinstall it

    I have put none optimisation options at all, I've double and triple check it. In the MSDN article, there is nothing more then this...

    If I comment all this file, it's just another file that is getting the error...
    Last edited by bibiteinfo; 02-01-2006 at 03:02 PM.

  7. #7
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    Then the problem is in one of the included files (or a file included by one of the included files).

    Use the code as it is posted above, and then try commenting out each include file one at a time, and see which one causes the error to move somewhere else. Whichever one it is will lead you further in your search.

  8. #8
    Registered User
    Join Date
    Feb 2006
    Posts
    10
    Code:
    template <class TYPE>
    int (*Liste_Mono<TYPE>::Compare) (const TYPE & Elem1, const TYPE & Elem2) = NULL;
    I finally found the bad line of code, but can someone tell me what is wrong in this line??

  9. #9
    Registered User
    Join Date
    Apr 2003
    Posts
    2,663
    What's the error message?

  10. #10
    Registered User
    Join Date
    Feb 2006
    Posts
    10
    C1001 Compilator error

  11. #11
    Tropical Coder Darryl's Avatar
    Join Date
    Mar 2005
    Location
    Cayman Islands
    Posts
    503
    [deleted]
    if you are just creating a function pointer, then leave of the = NULL part;

    Additionally if you are creating a pointer to a member function then the asterisk is in the wrong spot. This is probably what you want, but without seeing rest of code, can't be sure.

    Code:
    template <class TYPE>
    int (Liste_Mono<TYPE>::*Compare) (const TYPE & Elem1, const TYPE & Elem2)
    Last edited by Darryl; 02-02-2006 at 08:44 AM.

  12. #12
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    It's not a member function pointer (couldn't be a template) - seems more like a static member of Liste_Mono that is a function pointer.

    Can you post the declaration of the template Liste_Mono?
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  13. #13
    Registered User
    Join Date
    Feb 2006
    Posts
    10
    Code:
    template <class TYPE>
    class Liste_Mono
    {
    
    public:
    	static Cellule_MonoMemAllocator<TYPE> Allocator;
    
    public:
    	static int (*Compare)(const TYPE & Elem1, const TYPE & Elem2);
    .
    .
    .

    Thanx for all the help provided

  14. #14
    Tropical Coder Darryl's Avatar
    Join Date
    Mar 2005
    Location
    Cayman Islands
    Posts
    503
    I would say the line that is giving you trouble is useless/errant and can be removed entirely. It appears you are initializing the pointer to NULL, the way you might initialize a normal static member. But the fact that it is templated, means it doesn't exist until you actually use it so there is nothing to initialize.

    btw... good call cornedbeef

  15. #15
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    It's not about the initializing, it's that there will be linker errors if the line is removed.

    I think the line is simply overtaxing the compiler. Typedefs should always be used with function pointers; the syntax just gets too ugly otherwise.
    Code:
    public:
        typedef int (*COMPARATOR)(const TYPE &, const TYPE &);
        static COMPARATOR Compare;
    };
    
    template <typename TYPE>
    Liste_Mono<TYPE>::COMPARATOR Liste_Mono<TYPE>::Comparer = NULL;
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. migrate from .Net 2.0 to .Net 3.0
    By George2 in forum C# Programming
    Replies: 3
    Last Post: 07-25-2007, 04:07 AM
  2. Allegro Problems with Visual C++ .net 2003
    By LiNeAr in forum Game Programming
    Replies: 12
    Last Post: 10-16-2005, 06:51 PM
  3. Problems installing GLUT in .NET 2003
    By Kaminaga in forum Game Programming
    Replies: 4
    Last Post: 08-18-2005, 05:33 PM
  4. VS .NET 2003 Is Bloat!
    By UnregdRegd in forum A Brief History of Cprogramming.com
    Replies: 14
    Last Post: 02-29-2004, 10:51 PM
  5. Question about VS 6.0 vs. VS .NET
    By Guyver03 in forum C++ Programming
    Replies: 3
    Last Post: 12-19-2003, 01:42 PM