Thread: ...linker error...

  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    9

    Unhappy ...linker error...

    i'm using Dev++ now.

    And i got a linker error when i compile this...

    #include <stdio.h>
    #include <conio.h>


    int main ( void )
    {
    textcolor(BLUE);

    cprintf( "This is a test\n" );
    getch();
    return 0;
    }


    Can anyone spot and tell me wat to add?
    THANKS...

  2. #2
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    do

    int main()

    not

    int main(void)

  3. #3
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    int main(void)
    is correct c and equivalent to
    int main()
    in c++

    i.e. in c++ there is no difference between
    int main() and int main(void)
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

  4. #4
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    Your linker errors are probably down to cprintf() or textcolor(). Read the faq for text colouring details on a windows box. dev-c uses mingw as its compiler. This is a windows compiler.
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

  5. #5
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    Originally posted by Stoned_Coder
    int main(void)
    is correct c and equivalent to
    int main()
    in c++

    i.e. in c++ there is no difference between
    int main() and int main(void)
    hmm, i never knew that, but i guess it would make sense.....rather than use either or would it be better to use

    Code:
    int main(int argc, char* argv[])
    {
    }
    ?

    //also, sometimes when i let VC 6.0 create my cpp file for me and it uses that with stdafx header sometimes it'll compile error that it cant open that header file, but then i make another one the same way and it works....
    Last edited by RoD; 03-31-2003 at 02:39 PM.

  6. #6
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    Its best to keep things simple....

    in c you want

    int main(void)
    or if you are using command line args...
    int main( int argc,char* argv[])
    or its functional equivalent...
    int main( int argc,char**argv)

    in c++

    int main()
    or if using commandline args same as for c.
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

  7. #7
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    thnx man

  8. #8
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    You've been here how long, and you don't read the FAQ on main() usage?
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Errors including <windows.h>
    By jw232 in forum Windows Programming
    Replies: 4
    Last Post: 07-29-2008, 01:29 PM
  2. Crazy errors caused by class, never seen before..
    By Shamino in forum C++ Programming
    Replies: 2
    Last Post: 06-10-2007, 11:54 AM
  3. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 10:03 AM
  4. pointer to array of objects of struct
    By undisputed007 in forum C++ Programming
    Replies: 12
    Last Post: 03-02-2004, 04:49 AM
  5. Linking error
    By DockyD in forum C++ Programming
    Replies: 10
    Last Post: 01-20-2003, 05:27 AM