Find the answer to your Linux question:
Results 1 to 8 of 8
Hi, I'm a newbie to linux and using gcc under that environment. I have a real simple program in c and am using the gcc compiler and I am having ...
  1. #1
    Just Joined!
    Join Date
    Oct 2009
    Posts
    1

    Trouble compiling simple hello world program

    Hi,

    I'm a newbie to linux and using gcc under that environment.

    I have a real simple program in c and am using the gcc compiler and I am having trouble compiling the code. The code is thus:

    Code:
    #include <stdio.h>
    
    int main(void)
    {
    
    printf("Hello world");
    }
    I use the following the compile:

    gcc -o program main.c

    I get the following error message at the top of the output:

    in file included from /usr/include/stdio.h:75
    from main.c:2:

    /usr/include/libio.h:332: error: expected specifier-qualifier-list before size_t


    Can anyone help me resolve this error?

    Thanks,

    Chris.

  2. #2
    Linux Newbie
    Join Date
    Nov 2007
    Location
    Planet Earth
    Posts
    152
    There is no error in your program... AFAIK, that was a bug on last year version of gcc in certain distributions (I think debian and related) ... try to upgrade your compiler package in your package manager.

    Hugo
    EOF

  3. #3
    Linux User
    Join Date
    Aug 2006
    Posts
    458
    is this for school or for your own lesson in programming? If its the latter, there's no need to use C/C++. There are other excellent programming languages that can help you with programming..eg Python, Perl etc

  4. #4
    Linux Guru Lakshmipathi's Avatar
    Join Date
    Sep 2006
    Location
    3rd rock from sun - Often seen near moon
    Posts
    1,568

    Exclamation

    Quote Originally Posted by hugortega View Post
    There is no error in your program... AFAIK, that was a bug on last year version of gcc in certain distributions (I think debian and related) ... try to upgrade your compiler package in your package manager.

    Hugo
    I agree with Hugo, Seems like an issue with gcc Install recent version of gcc and try again.

    Quote Originally Posted by ghostdog74 View Post
    If its the latter, there's no need to use C/C++. There are other excellent programming languages that can help you with programming..eg Python, Perl etc
    It's true,languages like python is amazing (I'm learning it) ,but I would recommend C.
    Learning languages will always great,so try to learn as much as you can.
    - Lakshmipathi.G
    -------------------
    FOSS India Award winning ext3fs Undelete tool and tutorials www.giis.co.in
    First they criticize you,Then they laugh at you,Then they fight with you,Then you win. - M.K.Gandhi
    -------------------

  5. #5
    Linux Guru coopstah13's Avatar
    Join Date
    Nov 2007
    Location
    NH, USA
    Posts
    3,149
    Quote Originally Posted by ghostdog74 View Post
    is this for school or for your own lesson in programming? If its the latter, there's no need to use C/C++. There are other excellent programming languages that can help you with programming..eg Python, Perl etc
    There is no reason to discourage one from learning a certain language. A programming language is merely a tool and the more tools in your belt the better off you are. The best rule is to use the best tool for the job, and the more tools you have, the more choices for which one to use.

  6. #6
    Linux User
    Join Date
    Aug 2006
    Posts
    458
    Quote Originally Posted by coopstah13 View Post
    The best rule is to use the best tool for the job, and the more tools you have, the more choices for which one to use.
    there you said it.. best tool for the job. If OP is programming drivers, doing game programming, or other low level stuff, sure, he can learn C. BUT for normal everyday stuffs, eg parsing files, formatting text, doing OS stuff like coping files, backing up files etc...There is no need to learn C/C++. He doesn't need to learn about pointers etc...
    This guy is already struggling with C due to compiler problems...How much time has he wasted?
    how much time does he need to learn this ?
    Code:
    #!/usr/bin/env python
    print "hello world"
    That's what choosing a good programming language to learning programming is. less hassle, more productivity.

  7. #7
    Linux Guru coopstah13's Avatar
    Join Date
    Nov 2007
    Location
    NH, USA
    Posts
    3,149
    You're making many assumptions. I would not assume the OP has no programming experience and I would not assume what the OP is intending to do. MANY applications and libraries are written in C and C++. Perhaps OP is intending on contributing to one of these applications? We don't know, my only point in the previous post was not to discourage anything. Besides, how do you think python knows how to do what it does? That C back end is there for a reason.

  8. #8
    Linux User
    Join Date
    Aug 2006
    Posts
    458
    Quote Originally Posted by coopstah13 View Post
    You're making many assumptions.
    that's why i asked OP whether he is doing homework or not..right?
    MANY applications and libraries are written in C and C++.
    so? what's important is how one think about solving the problem..not getting nitty gritty into the lower level details.
    Perhaps OP is intending on contributing to one of these applications? We don't know, my only
    that's why i asked OP right?

    point in the previous post was not to discourage anything.
    that's why i asked. Now, if his answer is say, file parsing, do you think he need to do up a C program for that?

    Besides, how do you think python knows how to do what it does? That C back end is there for a reason.
    I don't need to know the backend of Python to know how to program in Python, do i? what's your point?

Posting Permissions

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