Thread: Compiling in C mode

  1. #1
    Registered User
    Join Date
    Aug 2007
    Posts
    4

    Compiling in C mode

    I am trying to compile the Quake (original) source with the Code::Blocks IDE and the MinGW compiler. Early in the compilation process I am getting a number of nasty errors that all trace back to the use of the word 'inline' as a variable name. So my question is, how do I force the compiler to compile in C mode as opposed to C++?

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    inline is also a C99 keyword, and recent versions of GCC (of which MinGW is one port) support C99.

    Assuming that the filenames end in .c, and you're invoking the compiler with 'gcc', then you could try adding this flag to the command line options
    Code:
    $ cat foo.c
    #include<stdio.h>
    
    int main ( ) {
        int inline = 0;
        printf("%d\n", inline );
        return 0;
    }
    
    $ gcc foo.c
    foo.c: In function `main':
    foo.c:4: error: parse error before '=' token
    foo.c:5: error: parse error before "inline"
    $ gcc --std=c89 foo.c
    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.

  3. #3
    Its hard... But im here swgh's Avatar
    Join Date
    Apr 2005
    Location
    England
    Posts
    1,688
    Am I correct in thinking ID software only released certain parts of the game as open source code? I know they also released doom 1 and 2 source code.

    Im still wating for the day Psygnosis release the source to lemmings as I know the core code must of been C, going by the original release date of the game. Since Psygnosis faded I dont decided not to release any code from quite amazing games "Shadow of the Beast" - AMOS Destruction Derby etc...

    Oh well maybe one day...
    Double Helix STL

  4. #4
    Registered User
    Join Date
    Aug 2007
    Posts
    4
    Thanks! That got rid of the errors relating to the 'inline' variable. Unfortunately I got a whole slew of new errors, most of them having to do with size_t variables (I take it size_t was not built into the C89 standard). Oh well, I went ahead and changed every occurrence of 'inline' to '_inline' (turns out it was only used a few times in the code) and reset to the default compiler flags (no --std=c89). Anyway, thanks for the response.

  5. #5
    Registered User
    Join Date
    Aug 2007
    Posts
    4
    Quote Originally Posted by swgh View Post
    Am I correct in thinking ID software only released certain parts of the game as open source code? I know they also released doom 1 and 2 source code.
    They released the entire source code, but certain elements of the game were not made open source (basically the .PAK files). As far as the Doom source, I can't speak about Doom 2, but I believe the Doom 1 source code that ID released was the Linux port of the game.

  6. #6
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    Current releases:

    * Quake 1-3
    * Doom

    Still waiting for Quake 4

  7. #7
    Registered User
    Join Date
    Sep 2006
    Posts
    835
    Quote Originally Posted by ulrichmc View Post
    Thanks! That got rid of the errors relating to the 'inline' variable. Unfortunately I got a whole slew of new errors, most of them having to do with size_t variables (I take it size_t was not built into the C89 standard). Oh well, I went ahead and changed every occurrence of 'inline' to '_inline' (turns out it was only used a few times in the code) and reset to the default compiler flags (no --std=c89). Anyway, thanks for the response.
    size_t is part of C89 (it's very basic, being the type of malloc()'s argument, among other things). What types of errors did you get? Did you #include <stddef.h> which should be included whenever size_t is used?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. console mode and service mode
    By George2 in forum C# Programming
    Replies: 0
    Last Post: 06-01-2008, 01:42 AM
  2. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  3. Shortening main
    By pdstatha in forum C Programming
    Replies: 1
    Last Post: 04-03-2002, 04:56 PM
  4. Implementing "ls -al"
    By pdstatha in forum Linux Programming
    Replies: 11
    Last Post: 03-20-2002, 04:39 AM
  5. Implementing "ls -al"
    By pdstatha in forum C Programming
    Replies: 7
    Last Post: 03-06-2002, 05:36 PM