Thread: Weird errors

  1. #1
    Registered User kinghajj's Avatar
    Join Date
    Jun 2003
    Posts
    218

    Weird errors

    Using Dev-Cpp.

    Code:
    // in a header file
    Register *getReg(Vm *, int);
    Error: parse error before * token

    I think it means the * token in "Vm *".

    Any ideas on what this means?
    01011001 01101111 01110101 00100000 01110100 01101111 01101111 1101011 00100000 01110100 01101000 01101001 01110011 00100000 01101101 01110101 01100011 01101000 00100000 01110100 01101000 01101101 01100101 00100000 01110100 01101111 00100000 01110010 01100101 01100001 01100100 00100000 01011001 01101000 01101001 01110011 00111111 00100000 01000100 01100001 01101101 01101110 00100001 00000000

  2. #2
    Registered User
    Join Date
    Sep 2004
    Posts
    719
    it either means "Register" is not a type, or "Vm" is not a type
    i seem to have GCC 3.3.4
    But how do i start it?
    I dont have a menu for it or anything.

  3. #3
    Registered User kinghajj's Avatar
    Join Date
    Jun 2003
    Posts
    218
    That's not the problem:

    Code:
    // in the same header file
    struct REGISTER {
    	unsigned long value;
    };
    
    typedef struct REGISTER Register;
    
    // in a file included by the header file
    struct VM {
    	Register a, b, c, d;
    	char *bcode;
    	unsigned int bcsize;
    	unsigned int i;
    };
    
    typedef struct VM Vm;
    01011001 01101111 01110101 00100000 01110100 01101111 01101111 1101011 00100000 01110100 01101000 01101001 01110011 00100000 01101101 01110101 01100011 01101000 00100000 01110100 01101000 01101101 01100101 00100000 01110100 01101111 00100000 01110010 01100101 01100001 01100100 00100000 01011001 01101000 01101001 01110011 00111111 00100000 01000100 01100001 01101101 01101110 00100001 00000000

  4. #4
    Registered User
    Join Date
    Mar 2005
    Posts
    37
    Hi,



    Code:
    // in the same header file
    struct REGISTER {
    	unsigned long value;
    };
    
    typedef struct REGISTER Register;
    
    // in a file included by the header file
    struct VM {
    	Register a, b, c, d;
    	char *bcode;
    	unsigned int bcsize;
    	unsigned int i;
    };
    
    typedef struct VM Vm;


    have you made above declaration before using it ?

    Code:
    // in a header file
    Register *getReg(Vm *, int);

  5. #5
    Registered User kinghajj's Avatar
    Join Date
    Jun 2003
    Posts
    218
    Yes, of course. The structs are above the prototypes.

    Update: if I change the "Vm *" to "int", (somehow!) Dev-Cpp compiles it, then if I change it to "Vm *" again, it compiles it that one time. Maybe it's a bug in GCC or MingW?
    01011001 01101111 01110101 00100000 01110100 01101111 01101111 1101011 00100000 01110100 01101000 01101001 01110011 00100000 01101101 01110101 01100011 01101000 00100000 01110100 01101000 01101101 01100101 00100000 01110100 01101111 00100000 01110010 01100101 01100001 01100100 00100000 01011001 01101000 01101001 01110011 00111111 00100000 01000100 01100001 01101101 01101110 00100001 00000000

  6. #6
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,005
    Quote Originally Posted by kinghajj
    Maybe it's a bug in GCC or MingW?
    Be sure.

    Full context in the question always leads to better answers.
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  7. #7
    Registered User kinghajj's Avatar
    Join Date
    Jun 2003
    Posts
    218
    Here's the headers:

    vm.h
    Code:
    #ifndef VM_H
    #define VM_H
    
    #include "register.h"
    
    struct VM {
    	Register a, b, c, d;
    	char *bcode;
    	unsigned int bcsize;
    	unsigned int i;
    };
    
    typedef struct VM Vm;
    
    Vm *createVm(char *, int);
    int runVm(Vm *);
    
    #endif
    register.h
    Code:
    #ifndef REGISTER_H
    #define REGISTER_H
    
    #include "vm.h"
    #include "bc.h"
    
    struct REGISTER {
    	unsigned long value;
    };
    
    typedef struct REGISTER Register;
    
    Register *getReg(Vm *, int); // error here
    void setValue(Register *, unsigned long);
    
    #endif
    If you haven't guessed, it's a VM. (Not a serious project; just having fun).

    Hope this helps.
    01011001 01101111 01110101 00100000 01110100 01101111 01101111 1101011 00100000 01110100 01101000 01101001 01110011 00100000 01101101 01110101 01100011 01101000 00100000 01110100 01101000 01101101 01100101 00100000 01110100 01101111 00100000 01110010 01100101 01100001 01100100 00100000 01011001 01101000 01101001 01110011 00111111 00100000 01000100 01100001 01101101 01101110 00100001 00000000

  8. #8
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,005
    Code:
    Error E2209 register.h 5: Unable to open include file 'bc.h'
    [Commenting that out, and making other assumptions...] Why do these headers include each other? How about this?
    Code:
    /* register.h */
    #ifndef REGISTER_H
    #define REGISTER_H
    
    //#include "bc.h"
    
    struct REGISTER {
    	unsigned long value;
    };
    
    typedef struct REGISTER Register;
    
    
    #endif
    Code:
    /* vm.h */
    #ifndef VM_H
    #define VM_H
    
    #include "register.h"
    
    struct VM {
    	Register a, b, c, d;
    	char *bcode;
    	unsigned int bcsize;
    	unsigned int i;
    };
    
    typedef struct VM Vm;
    
    Vm *createVm(char *, int);
    int runVm(Vm *);
    Register *getReg(Vm *, int);
    void setValue(Register *, unsigned long);
    
    #endif
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. HELP with DX9 Errors!!!
    By Tommaso in forum Game Programming
    Replies: 7
    Last Post: 06-28-2006, 02:51 PM
  2. Errors with header files in OpenGL using VisualC++
    By wile_spice in forum Game Programming
    Replies: 3
    Last Post: 06-22-2006, 08:56 AM
  3. Weird Errors in VS 2003
    By Devil Panther in forum Windows Programming
    Replies: 1
    Last Post: 10-01-2005, 06:16 AM
  4. executing errors
    By s0ul2squeeze in forum C++ Programming
    Replies: 3
    Last Post: 03-26-2002, 01:43 PM