Thread: gcc -c error

  1. #1
    Registered User Tommo's Avatar
    Join Date
    Jun 2007
    Location
    Scotland
    Posts
    101

    gcc -c error

    Hi.

    Im having some trouble creating some object files using the c flag for gcc

    fred.c
    Code:
    #include <stdio.h>
    
    void fred(int arg)
    {
        printf(“fred: you passed %d\n”, arg);
    }
    bill.c
    Code:
    #include <stdio.h>
    
    void bill(char *arg)
    {
        printf(“bill: you passed %s\n”, arg);
    }
    Code:
    $gcc -c fred.c - fred.c bill.c
    fred.c: In function ‘fred’:
    fred.c:5: error: stray ‘\342’ in program
    fred.c:5: error: stray ‘\200’ in program
    fred.c:5: error: stray ‘\234’ in program
    fred.c:5: error: expected ‘)’ before ‘:’ token
    fred.c:5: error: stray ‘\’ in program
    fred.c:5: error: stray ‘\342’ in program
    fred.c:5: error: stray ‘\200’ in program
    fred.c:5: error: stray ‘\235’ in program
    fred.c:5: warning: passing argument 1 of ‘printf’ from incompatible pointer type
    bill.c: In function ‘bill’:
    bill.c:5: error: stray ‘\342’ in program
    bill.c:5: error: stray ‘\200’ in program
    bill.c:5: error: stray ‘\234’ in program
    bill.c:5: error: expected ‘)’ before ‘:’ token
    bill.c:5: error: stray ‘\’ in program
    bill.c:5: error: stray ‘\342’ in program
    bill.c:5: error: stray ‘\200’ in program
    bill.c:5: error: stray ‘\235’ in program
    bill.c:5: warning: passing argument 1 of ‘printf’ from incompatible pointer type
    Google is of no help on this one. It should create fred.o and bill.o. Strange.

    Any ideas?

  2. #2
    Registered User Tommo's Avatar
    Join Date
    Jun 2007
    Location
    Scotland
    Posts
    101
    OK, that was really annoying. Right after I posted that I noticed the double quotes looked wierd. So I edited fred.c and bill.c and replaced them with normal double quotes and voila! Personally, I don't see how there can be an alternative double quote but there you have it.

    Code:
    $ gcc -c bill.c fred.c
    $ ls *.o
    bill.o fred.o
    swish

  3. #3
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    Those are the "pretty" quotes used for typesetting. For programming, such things are quite useless, of course.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  4. #4
    Registered User Tommo's Avatar
    Join Date
    Jun 2007
    Location
    Scotland
    Posts
    101
    Haha ok. I copied it over from a pdf file, which explains everything really.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Testing some code, lots of errors...
    By Sparrowhawk in forum C Programming
    Replies: 48
    Last Post: 12-15-2008, 04:09 AM
  2. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 01:01 AM
  3. Connecting to a mysql server and querying problem
    By Diod in forum C++ Programming
    Replies: 8
    Last Post: 02-13-2006, 10:33 AM
  4. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 02:53 AM
  5. Linking error
    By DockyD in forum C++ Programming
    Replies: 10
    Last Post: 01-20-2003, 05:27 AM