Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Compile using PellesC

mr_jackmr_jack Posts: 11Member
Hello Everybody!

I have a problem with Pelles C IDE:
i am writing a simple C program that use socket connection (TCP,UDP...)
and i have inclused winsock.h and winsock2.h library in the source code.
When i try to compile, Pelles (cc.exe -> the compiler) answers with a lot
of error like:

C:PellesCIncludeWinwinreg.h(173): warning #2203: Function 'RegFlushKey' can't be __stdcall, changed to __cdecl.
C:PellesCIncludeWinwinreg.h(174): warning #2203: Function 'RegGetKeySecurity' can't be __stdcall, changed to __cdecl.

Why???? What have i to do???

I am absolutely sure that the code is correct because i have already compiled it in Linux (gcc...)(with the correct library) ad it run.

A last thing:

C:PellesCIncludeWindde.h(32): error #2186: 'unsigned short int' is an illegal bit-field type.

why??? unsigned short or int isn't ansi c???

Thank you very much!!!

Comments

  • stoberstober Posts: 9,765Member ✭✭✭
    >> Why???? What have i to do???

    maybe because you have a shitty compiler??? get one that's more frequently used, such as Dev-C++, Borland Builder, or Microsoft VC++ 2005 Express.



  • LundinLundin Posts: 3,711Member
    [b][red]This message was edited by Lundin at 2006-8-28 23:27:2[/red][/b][hr]
    : C:PellesCIncludeWindde.h(32): error #2186: 'unsigned short int' is an illegal bit-field type.

    ANSI C says that only allowed type for bitfields is unsigned int.
    Stupid, but that is what the standard says. Some compilers implements other types, but using any other type than int is undefined behavior.

    Bitfields in general only causes trouble, I never use them. I have yet to see two compilers implementing them in the same way. Bitwise operators work just as fine and will yield exactly the same machine code as bitfields in the end.

    Things causing trouble when using bitfields:

    - Some int types are not allowed.
    - Arrays of bitfields are implemented differently on different compilers.
    - Struct padding.
    - Big/little endian.
    - Is the first bit in the struct msb or lsb?
    - What happens to unused bits?

    etc etc. Don't use them, imo.




  • mr_jackmr_jack Posts: 11Member
    [b][red]This message was edited by mr_jack at 2006-8-29 11:40:13[/red][/b][hr]
    First, thank you for your answer (Lundin too)!
    Second:

    >>Dev-C++

    I have already used this IDE many times, but it gave me the same errors...
    (dev-c++ uses gcc compiler the same that i have used in Linux with success)

    >>Borland Builder, or Microsoft VC++ 2005 Express.

    I am only a student therefor i cannot pay for these expensive IDE(Borland C++Builder 2006-Enterprise $2,490.00)... if exists a free version of these IDE i will be happy to try them!

    Thank you again!

    mr_jack




  • stoberstober Posts: 9,765Member ✭✭✭
    : >>Borland Builder, or Microsoft VC++ 2005 Express.
    :
    : I am only a student therefor i cannot pay for these expensive IDE(Borland C++Builder 2006-Enterprise $2,490.00)... if exists a free version of these IDE i will be happy to try them!
    :
    : Thank you again!
    :
    : mr_jack
    :
    :
    :
    :
    :

    Both those compilers are free. I did NOT suggest the Enterprise editions because of outragous cost. There are free versions of both those compilers.
    http://msdn.microsoft.com/vstudio/express/visualc/download/
  • LundinLundin Posts: 3,711Member
    : : >>Borland Builder, or Microsoft VC++ 2005 Express.
    : :
    : : I am only a student therefor i cannot pay for these expensive IDE(Borland C++Builder 2006-Enterprise $2,490.00)... if exists a free version of these IDE i will be happy to try them!
    : :
    : : Thank you again!
    : :
    : : mr_jack
    : :
    : :
    : :
    : :
    : :
    :
    : Both those compilers are free. I did NOT suggest the Enterprise editions because of outragous cost. There are free versions of both those compilers.
    : http://msdn.microsoft.com/vstudio/express/visualc/download/
    :


    Download Borland's command line compiler here:

    http://www.winprog.org/tutorial/bcpp.html

    At www.borland.com they also have "C++ BuilderX" for free, which is an IDE for that compiler. The download is rather huge though.

  • crazybeardedmacrazybeardedma Posts: 1Member
    I know this is old, but I came across it and thought I would offer an answer for anyone else who runs into this "problem".

    Actually, it isn't a problem. PellesC just happens to be a) ansi compliant, and b) assumes you know what your are doing and doesn't attempt to read your mind.

    In other words, it attempts to compile using ansi standards unless you tell it different. MS isn't ansi compliant (well, sort of, it just did the old "embrace and enhance" borgish thing it does with everything else).

    "Great, so how do I compile the bloody thing?!" Alright, alright! Open your project options and go to the "Compiler" properties sheet (click the tab). In the options group check "Enable Microsoft extensions". Now, under "Calling conv" use the drop down to select "__stdcall".

    Also make sure you have included the wsock32.lib. This comes with PellesC. Under the Linker tab type "wsock32.lib" (without quotes) in the "Library and object files" field.

    Click OK and recompile your project.

    That should do it (well, it did for me). I compiled a project with winsock and initiallized the WSAData just to make sure.

    I hope that helps anyone else using this really cool compiler and IDE for C dev.

    Yours,
    cbm



    : Hello Everybody!
    :
    : I have a problem with Pelles C IDE:
    : i am writing a simple C program that use socket connection
    : (TCP,UDP...)
    : and i have inclused winsock.h and winsock2.h library in the source
    : code.
    : When i try to compile, Pelles (cc.exe -> the compiler) answers with
    : a lot
    : of error like:
    :
    : C:PellesCIncludeWinwinreg.h(173): warning #2203: Function
    : 'RegFlushKey' can't be __stdcall, changed to __cdecl.
    : C:PellesCIncludeWinwinreg.h(174): warning #2203: Function
    : 'RegGetKeySecurity' can't be __stdcall, changed to __cdecl.
    :
    : Why???? What have i to do???
    :
    : I am absolutely sure that the code is correct because i have already
    : compiled it in Linux (gcc...)(with the correct library) ad it run.
    :
    : A last thing:
    :
    : C:PellesCIncludeWindde.h(32): error #2186: 'unsigned short int'
    : is an illegal bit-field type.
    :
    : why??? unsigned short or int isn't ansi c???
    :
    : Thank you very much!!!
    :

Sign In or Register to comment.