Thread: Compile error - what does it mean?

  1. #1
    Registered User
    Join Date
    Apr 2011
    Posts
    8

    Compile error - what does it mean?

    Hi,

    I've just registered in this forum because I'm sad of beeing lots of time to debug code when the problem is, afterall, too simple to resolve.

    This time, I simply don't understand what the compiler is trying to tell me.

    As I'm doing a work for university, I'm not writing comments and variable names in English, so I'll try to avoid posting code.

    I just can't understand what's the meaning of

    « Item_is_voo.h:10: error: storage class specified for parameter ‘Item’ »

    Can someone tell me in a language that an amateur programmer can understand what does it mean? If you can't help me I'll try to translate the everything to English and post the code.



    Thank you,
    J. Miranda

  2. #2
    Registered User
    Join Date
    May 2010
    Posts
    4,632
    Although we may not speak your language, we do understand C so don't be afraid to post your code. As to your error message, without seeing the entire exact error message and the code that generated this message it is hard to tell what is wrong. So please post the code for Item_is_voo.h and the complete error message.

    Jim

  3. #3
    Registered User
    Join Date
    Apr 2011
    Posts
    8
    Ok, sure.

    Error:

    Code:
    miranda@ubuntu:~/Desktop/proj2$ make -s all
    In file included from ADT.c:5:
    Item_is_voo.h: In function ‘LISTdeleteel’:
    Item_is_voo.h:10: error: storage class specified for parameter ‘Item’
    Item_is_voo.h:12: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
    ...

    I'm resolving the bugs step by step so I think the next errors are not important but feel free to ask if you need more information.


    LISTdeleteel is a function that deletes the first element of a basic linked list. I've tested all the functions of the type "voo" and tested all the list functions when Item is int. Now I want to make a list of pointers to the type "voo" and I'm getting that error.






    Item_is_voo.h

    Code:
    /* Item_is_voo.h - Definições para Item = voo */
    
    #if defined __Item__
    #undefine __Item__
    #endif
    
    #include <stdlib.h>
    #include "ADT.h"
    
    typedef voo *Item;
    
    voo *NEW(voo v) {
      voo *temp;
      
      temp = (voo *) malloc(sizeof(voo));
    
      return temp;
    }
    On ADT.c

    Code:
    #include "ADT.h"
    #include "Item_is_voo.h"
    
    #include <stdlib.h>
    ...

    Code:
    /* LISTdeleteel
    
       LISTdeleteel(ptrlst) altera a lista apontada por
    
       <ptrlst>, apagando o primeiro elemento. */
    
    void LISTdeleteel(list *ptrhead) {
    
      link temp;
    
      
    
      temp = *ptrhead;
    
      *ptrhead = (*ptrhead)->next;
    
      free(temp);
    
    }
    ADT.h

    Code:
    /* ADT.h -- definições e declarações globais
    
    para o ficheiro ADT.c            */
    
    
    
    #if !defined __tai__
    
    #define __tai__
    
    
    
    /* Definições de tipos (as operações básicas
    
    estão definidas no ficheiro ADT.c */
    
    
    
    /* Tipo vôo */
    
    struct voo {
    
      char cod[7];
    
      char orig[4];
    
      char dest[4];
    
      int horaspartida;
    
      int minspartida;
    
      int horaschegada;
    
      int minschegada;
    
      float preco;
    
    };
    
    
    
    typedef struct voo voo;
    
    /* Tipo lista simplificada */
    
    #include "Item_is_voo.h"
    
    
    struct node {
    
      Item value;
    
      struct node *next;
    
    };
    
    
    
    typedef struct node *link;
    
    typedef struct node *list;
    
    
    
    /* Declaração das funções definidas
    
    no ficheiro ADT.c (operações básicas e operações de alto nível) */
    
    
    
    voo cria_voo(char*, char*, char*, int, int, int, int, float);
    
    char *cod_voo(voo);
    
    char *orig_voo(voo);
    
    char *dest_voo(voo);
    
    int horaspartida_voo(voo);
    
    int minspartida_voo(voo);
    
    int horaschegada_voo(voo);
    
    int minschegada_voo(voo);
    
    float preco_voo(voo);
    
    void adiavoo(voo*, int, int);
    
    
    
    list LISTnew();
    
    void LISTinsert(Item, list*);
    
    Item LISTfirst(list);
    
    list LISTrest(list);
    
    void LISTdeleteel(list*)
    
    int LISTtestifempty(list);
    
    
    
    #endif

  4. #4
    Registered User
    Join Date
    Apr 2008
    Posts
    90
    In ADT.h, you have this:

    Code:
    void LISTdeleteel(list*)
    When you should probably have this:

    Code:
    void LISTdeleteel(list*);
    Note the missing semicolon. The result is that the compiler thinks that everything that follows is part of a function definition, particularly the typedef where the error is being triggered.

  5. #5
    Registered User
    Join Date
    Apr 2011
    Posts
    33
    This error from gcc might mean you have forgotten a semicolon after a function prototype. Check your header files.

  6. #6
    Registered User
    Join Date
    Apr 2011
    Posts
    8
    Yes, that was the problem, thank you. Sadly my tired eyes weren't noticing it. As I didn't test the header, but tested the file ADT.c, I assumed that everything there was correct :|

    I've corrected almost all the other errors and warnings but I'm still confused with the last one.

    Now the problem is:

    miranda@ubuntu:~/Desktop/proj2$ make -s all
    /tmp/ccQwg26M.o: In function `makeItem':
    input_read.c.text+0x0): multiple definition of `makeItem'
    /tmp/ccBGZZ0C.o:list.c.text+0x0): first defined here
    collect2: ld returned 1 exit status
    make: *** [all] Error 1
    Well, the unique file where makeItem is beeing define is Item_is_voo.h . Also, It seems that the error is after preprocessing (if I'm not wrong, that's told by the error message). So, what might be causing this?

  7. #7
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,662
    You need to separate declarations into .h files, and definitions into .c files.

    This is wrong.
    Item_is_voo.h
    Code:
    /* Item_is_voo.h - Definições para Item = voo */
    
    #if defined __Item__
    #undefine __Item__
    #endif
    
    #include <stdlib.h>
    #include "ADT.h"
    
    typedef voo *Item;
    
    voo *NEW(voo v) {
      voo *temp;
      
      temp = (voo *) malloc(sizeof(voo));
    
      return temp;
    }
    
    The red bit needs to be in a .c file, and replaced with this declaration
    Code:
    voo *NEW(voo v);
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  8. #8
    Registered User
    Join Date
    Apr 2011
    Posts
    8
    I thinked in that but I've done the same to make a list of integers and it worked. Also saw some examples where they did the same with integers and strings. As this is a more complex type, maybe it wont let me do the same.

    I'll follow your advice and post the result.

  9. #9
    Registered User
    Join Date
    Apr 2011
    Posts
    8
    It worked, thanks!

    So what do you suggest if I need to reuse the code to make a list of other type? Do I need to create more operations to distinguish, for example, a list of int's and a list of float's ? Or there's another way to replace "Item" multiple times in the same program, making it forget the last meaning of the function NEW ?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. compile time error or runtime error?
    By George2 in forum C# Programming
    Replies: 3
    Last Post: 05-07-2008, 07:08 AM
  2. Compile error... Resource error to :/.
    By Blackroot in forum Windows Programming
    Replies: 3
    Last Post: 08-23-2006, 05:09 PM
  3. 0 compile error but 2 build error. need help please!
    By jibbles in forum C Programming
    Replies: 5
    Last Post: 08-30-2004, 04:30 PM
  4. compile once, compile twice ...error
    By Benzakhar in forum Windows Programming
    Replies: 6
    Last Post: 12-28-2003, 06:00 AM
  5. error C2061 - Compile Error
    By GaGi in forum C++ Programming
    Replies: 1
    Last Post: 01-22-2002, 11:50 PM