Thread: Weird compiler (Dev)

  1. #1
    Registered User gavra's Avatar
    Join Date
    Jun 2008
    Posts
    265

    Weird compiler (Dev)

    I am using dev C++ and this compiler tends to make something weird:
    If I would like to use getch which belongs to conio.h and I won't include conio.h "he" won't "say" nothing - no errors\warnnings - and the program will work fine O: (the same thing with another function and another header)

    So WTF?!

    thanks (:
    Last edited by gavra; 08-01-2008 at 09:48 AM.
    gavra.

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    gcc (like most C compilers) do not REQUIRE prototypes for functions. It only warns when prototypes are missing. If you do not enable warnings (or ignore them) then you don't get any complaint from the compiler. All standard function libraries are linked against anyways, whether you included the header file or not.

    You should enable warnings (-Wall to the compiler - how you get dev-c++ to give the compiler that warning, I'm not quite sure).

    Compiling as C++ will possibly give you more errors/warnings if you miss out a header file, because the C++ language is somewhat more strict on the subject of prototypes. [que Elysia posting that C++ is better than C].

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Its hard... But im here swgh's Avatar
    Join Date
    Apr 2005
    Location
    England
    Posts
    1,688
    I used to use dev 4.992 and this would be absolutly fine:

    Code:
    #include <stdio.h>
    
    int main()
    {
       printf("How do I compille!\n");
    
       getch();
    
       return 0;
    }
    Double Helix STL

  4. #4
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by swgh View Post
    I used to use dev 4.992 and this would be absolutly fine:
    Yes, in fact:
    Code:
    int main()
    {
       printf("How do I compille!\n");
    
       getch();
    
       return 0;
    }
    will too.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  5. #5
    Technical Lead QuantumPete's Avatar
    Join Date
    Aug 2007
    Location
    London, UK
    Posts
    894
    Quote Originally Posted by matsp View Post
    [que Elysia posting that C++ is better than C].
    I think you mean "cue" - and Elysia, please don't!

    QuantumPete
    "No-one else has reported this problem, you're either crazy or a liar" - Dogbert Technical Support
    "Have you tried turning it off and on again?" - The IT Crowd

  6. #6
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    In C, it is "optional" to have a function prototype before calling a function, known as implicit function call. It is a very bad thing which you want to strive to avoid. Put warnings to maximum, and don't cast the return of functions and it should detect these things.
    In C++, this is an error.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  7. #7
    Registered User gavra's Avatar
    Join Date
    Jun 2008
    Posts
    265
    thanks
    humm how do I enable those warnnings?
    gavra.

  8. #8
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    In Dev-C++, under Tools -> Compiler Options, put "-Wall" in the "...commands when calling compiler" box.

  9. #9
    Registered User gavra's Avatar
    Join Date
    Jun 2008
    Posts
    265
    thank you.
    I really want the compiler to be more strict so should I add something (except "-Wall")?

  10. #10
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    -Wall is already "all" the warnings. If you want to be hardcore, you can do "-Werror", which means that all the warnings are turned into errors, so that you have to fix them.

  11. #11
    Registered User
    Join Date
    Jul 2008
    Posts
    133
    Usually -W is required in combination with -Wall (1st enables warnings, 2nd selects all warning). There are "-ansi" and "-pedantic" for purists ("-traditional" maybe?), at least in gcc...

  12. #12
    Registered User gavra's Avatar
    Join Date
    Jun 2008
    Posts
    265
    thank you again (:
    gavra.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Dev C++ compiler question
    By calsonicgtr in forum C Programming
    Replies: 2
    Last Post: 09-01-2008, 10:36 PM
  2. Compiler Paths...
    By Cobra in forum C++ Programming
    Replies: 5
    Last Post: 09-26-2006, 04:04 AM
  3. C Compiler and stuff
    By pal1ndr0me in forum C Programming
    Replies: 10
    Last Post: 07-21-2006, 11:07 AM
  4. DEV C++ Compiler Questions re: Color
    By pityocamptes in forum C++ Programming
    Replies: 6
    Last Post: 07-13-2006, 07:28 AM
  5. VC+6: weird compiler error
    By psychopath in forum Tech Board
    Replies: 7
    Last Post: 05-19-2005, 03:09 PM