Find the answer to your Linux question:
Results 1 to 6 of 6
Hi, I am writing simple program, which includes .h file which having structure defined as like this: ----------------------------------- /* main.h */ #ifndef _MAIN_H_ #define _MAIN_H_ 1 void Rules(); typedef struct ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Feb 2008
    Posts
    50

    gcc -c main.c In file included from main.c:1: Getting Error: expected specifier


    Hi,

    I am writing simple program, which includes .h file which having structure defined as like this:
    -----------------------------------
    /* main.h */
    #ifndef _MAIN_H_
    #define _MAIN_H_ 1
    void Rules();
    typedef struct _CRules{
    int var1;
    char *var2;
    bool var3
    } CRules;
    #endif
    ------------------------------------
    while compling my main.c i'm getting this error
    $gcc -c main.c
    In file included from main.c:1:
    main.h:11: error: expected specifier-qualifier-list before ‘bool’

    why this ??

    Thanks,

  2. #2
    Linux Engineer wje_lf's Avatar
    Join Date
    Sep 2007
    Location
    Mariposa
    Posts
    1,192
    Two problems.
    1. It would be best to put a semicolon (";") at the end of the var3 line.
    2. Have you actually defined the bool type anywhere?

    Hope this helps.
    --
    Bill

    Old age and treachery will overcome youth and skill.

  3. #3
    Just Joined!
    Join Date
    Feb 2008
    Posts
    50
    Thanks Bill,

    (1) I putted ";" at end of var3. But the same problem.
    (2) In code, I havn't defined anywhere bool
    my problem is, when i remove bool it compiles successfully, only bool is not working..

  4. $spacer_open
    $spacer_close
  5. #4
    Linux Engineer wje_lf's Avatar
    Join Date
    Sep 2007
    Location
    Mariposa
    Posts
    1,192
    One solution is to use int instead of bool.
    --
    Bill

    Old age and treachery will overcome youth and skill.

  6. #5
    Just Joined!
    Join Date
    Dec 2007
    Location
    Algeria
    Posts
    26
    the type bool doesn't exist in C, you have to define it first or use unsigned instead.

  7. #6
    Just Joined!
    Join Date
    Jul 2011
    Posts
    1
    Include the file stdbool.h file to your program. Thats it. In some version of GCC bool is defined in this file.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •