Thread: How to make Dev-C++ more C99 compliant ??

  1. #1
    C/C++Newbie Antigloss's Avatar
    Join Date
    May 2005
    Posts
    216

    How to make Dev-C++ more C99 compliant ??

    I am using Dev-C++ 4.9.9.2 . I found it not support the type long long. Here is my code
    Code:
    #include <stdio.h>
    
    int main(void)
    {
          unsigned int un = 3000000000; /* system with 32-bit int */
          short end = 200;              /* and 16-bit short       */
          long big = 65537;
          long long verybig = 12345678908642;
    
          printf("un = %u and not %d\n", un, un);
          printf("end = %hd and %d\n", end, end);
          printf("big = %ld and not %hd\n", big, big);
          printf("verybig= %lld and not %ld\n", verybig, verybig);
    
          getchar();
          return 0;
    }
    here is the warning message
    Quote Originally Posted by warning
    G:\Documents and Settings\antigloss\a.c In function `main':
    5 G:\Documents and Settings\antigloss\a.c [Warning] this decimal constant is unsigned only in ISO C90
    8 G:\Documents and Settings\antigloss\a.c [Warning] integer constant is too large for "long" type
    and the output
    Quote Originally Posted by output
    un = 3000000000 and not -1294967296
    end = 200 and 200
    big = 65537 and not 1
    verybig= 1942899938 and not 2874
    My question is how to set up dev-c++ so that it'll support the type long long ??

  2. #2
    Registered Luser cwr's Avatar
    Join Date
    Jul 2005
    Location
    Sydney, Australia
    Posts
    869
    Looks to me like it supports long long. Don't you need to append LL on the end of the constant, otherwise it treats it as just a long?

    Edit:

    Code:
          unsigned int un = 3000000000UL; /* system with 32-bit int */
          short end = 200;              /* and 16-bit short       */
          long big = 65537;
          long long verybig = 12345678908642LL;
    Last edited by cwr; 10-06-2005 at 02:12 AM.

  3. #3
    C/C++Newbie Antigloss's Avatar
    Join Date
    May 2005
    Posts
    216
    I tried this prog under linux using gcc3.2. It works very well.

    I've tried the suffix LL, but it didn't work. Seems like my version of devcpp didnt come with a c99 library ??

  4. #4
    Registered Luser cwr's Avatar
    Join Date
    Jul 2005
    Location
    Sydney, Australia
    Posts
    869
    Oh, the library is a separate issue. The compiler appears to support C99, otherwise the long long declaration would have been rejected. The library appears to not if %lld didn't result in correct output.

  5. #5
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    I've heard before that dev-c++ inherits the 'bugs' of the run-time library on which it runs (namely microsoft)
    http://msdn.microsoft.com/library/de..._functions.asp
    So I think you need to use the "I64" grubbyness when using long long variables in printf() conversions when programming in dev-c++.
    Normal arithmetic and parameter passing within your program should work as per the standard, it's just a pain to print them

    To make the compiler compile C99 code, if you have a reasonably new gcc compiler, then you could try adding "-std=c99" to the compiler command line.
    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.

  6. #6
    Registered User TactX's Avatar
    Join Date
    Oct 2005
    Location
    Germany.Stuttgart
    Posts
    65
    The gcc family had support for long long even before C99. It was an non-standard extension.

  7. #7
    Registered User
    Join Date
    Aug 2005
    Posts
    1,267
    Quote Originally Posted by Salem
    I've heard before that dev-c++ inherits the 'bugs' of the run-time library on which it runs (namely microsoft)
    I think you heard wrong -- by default dev-c++ (version 5) uses GNU gcc and g++ compilers, but can be changed to use any compiler you wish. standard runtime libraries are also from GNU, not M$.

    There are no compilers that are 100% C99 compliant -- Comeau is probably the closest.
    Last edited by Ancient Dragon; 10-06-2005 at 05:07 AM.

  8. #8
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,005
    Quote Originally Posted by Ancient Dragon
    I think you heard wrong -- by default dev-c++ (version 5) uses GNU gcc and g++ compilers, but can be changed to use any compiler you wish. standard runtime libraries are also from GNU, not M$.
    http://www.bloodshed.net/devcpp.html:
    Bloodshed Dev-C++ is a full-featured Integrated Development Environment (IDE) for the C/C++ programming language. It uses Mingw port of GCC (GNU Compiler Collection) as it's compiler. Dev-C++ can also be used in combination with Cygwin or any other GCC based compiler.
    http://www.mingw.org/docs.shtml#win32api:
    Win32 API Documentation
    MinGW uses the runtime libraries distributed with the OS, [...]
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  9. #9
    Registered User
    Join Date
    Aug 2005
    Posts
    1,267
    that's referring to the win32 api functions not the c or c++ runtime standard libraries. All compilers for MS-Windows os must use the MS-Windows api dlls and libraries and I would suspect the same applies to all other os as well.

  10. #10
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,005
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  11. #11
    Registered User
    Join Date
    Aug 2005
    Posts
    1,267
    Just because I say "the sky is falling" doesn't make it so. Kenneth Thompson (the author of that quote) may or may not be an authority on the subject. MS-Windows os does not supply the libraries when you install the os, they must be installed with the compiler. Since GNU has their own open-source compiler and libraries I assumed (maybe wrongly) that Dev-C++ installed and used those. I doubt Microsoft will authorize other compilers (competetors) to distribute Microsoft proprietry/copyright runtime libraries.

  12. #12
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    Dev-C++/MinGW uses msvcrt.dll, which is distributed as part of the OS.

  13. #13
    Registered User
    Join Date
    Sep 2004
    Posts
    44
    Dev-C++/MinGW uses msvcrt.dll, which is distributed as part of the OS.
    Correct, and msvcrt.dll does not support C99. The new Visual C/C++ 2005 compiler does not support C99 either, it's ridiculous.

    Note: Pelles C supports C99 and uses it's own runtime library.
    Last edited by n7yap; 10-06-2005 at 01:32 PM.

  14. #14
    Registered User
    Join Date
    Aug 2005
    Posts
    1,267
    Quote Originally Posted by anonytmouse
    Dev-C++/MinGW uses msvcrt.dll, which is distributed as part of the OS.
    I knew that -- just making sure you guys are paying attention Won't be the first or last time I'm proving wrong.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to make a Packet sniffer/filter?
    By shown in forum C++ Programming
    Replies: 2
    Last Post: 02-22-2009, 09:51 PM
  2. trying to make a KenGen ( for a game tool )
    By lonewolfy in forum C# Programming
    Replies: 4
    Last Post: 03-28-2007, 08:23 AM
  3. how to make a windows application
    By crvenkapa in forum C++ Programming
    Replies: 3
    Last Post: 03-26-2007, 09:59 AM
  4. Win32 Common Controls in C++, how do i make and use them?
    By C+noob in forum Windows Programming
    Replies: 6
    Last Post: 01-09-2006, 11:53 AM
  5. want to make this small program...
    By psycho88 in forum C++ Programming
    Replies: 8
    Last Post: 11-30-2005, 02:05 AM