Compile Question

This is a discussion on Compile Question within the Windows Programming forums, part of the Platform Specific Boards category; I have two questions: 1) Does Win32 API use C/C++ standard library or it has it own low level routines? ...

  1. #1
    System Novice siavoshkc's Avatar
    Join Date
    Jan 2006
    Location
    Tehran
    Posts
    1,231

    Compile Question

    I have two questions:
    1) Does Win32 API use C/C++ standard library or it has it own low level routines?
    2) Why should the compiler know the target environment? For example we should clarify "console" or "Win32" by corresponding switches while they both run in Windows platform.
    Learn C++ (C++ Books, C Books, FAQ, Forum Search)
    Code painter latest version on sourceforge DOWNLOAD NOW!
    Download FSB Data Integrity Tester.
    Siavosh K C

  2. #2
    Registered User
    Join Date
    Apr 2003
    Posts
    2,662
    A) There is a windows programming forum.
    1) The win32 api is written in C, and therefore follows the rules of C.
    2) Because a console program runs in DOS, and a windows program interacts with the windows operating system. A console program and a windows program are drastically different in structure and function. Create one of each and look at the differences. If you want to write a windows program, then you have to play by the rules that MS decided on.
    Last edited by 7stud; 03-12-2006 at 04:37 PM.

  3. #3
    System Novice siavoshkc's Avatar
    Join Date
    Jan 2006
    Location
    Tehran
    Posts
    1,231
    If you want to write a windows program, then you have to play by the rules that MS decided on.
    I have written both console and Win32 codes.
    How C/C++ compiler generates different machine code from the same C/C++ source code?
    Learn C++ (C++ Books, C Books, FAQ, Forum Search)
    Code painter latest version on sourceforge DOWNLOAD NOW!
    Download FSB Data Integrity Tester.
    Siavosh K C

  4. #4
    Registered User
    Join Date
    Apr 2003
    Posts
    2,662
    I have written both console and Win32 codes.
    How C/C++ compiler generates different machine code from the same C/C++ source code?
    The source code for a console program that displays 'hello world' in a DOS window, and the source code for a windows program that displays 'hello world' in a window are not the same. The windows program is more than 50 lines of source code.

  5. #5
    Registered User
    Join Date
    Aug 2003
    Posts
    470
    2) Why should the compiler know the target environment? For example we should clarify "console" or "Win32" by corresponding switches while they both run in Windows platform.
    When a win32 console program is run, a console window is created. You don't write the code to display the console window. But For win32 non-console programs, you must create your own windows. You can create a console window if you like, but one is not automatically created.

  6. #6
    System Novice siavoshkc's Avatar
    Join Date
    Jan 2006
    Location
    Tehran
    Posts
    1,231
    The source code for a console program that displays 'hello world' in a DOS window, and the source code for a windows program that displays 'hello world' in a window are not the same. The windows program is more than 50 lines of source code.
    It was not what I meant. Think you have a 50 lines code for Windows. Once compile it with the _CONSOLE switch and once without it (imagine that it will compile without any linkin' error).

    When a win32 console program is run, a console window is created. You don't write the code to display the console window. But For win32 non-console programs, you must create your own windows. You can create a console window if you like, but one is not automatically created.
    I know, what I mean is this:
    There is a C++ code.
    There is a C++ compiler.
    Then there should be a machine code after compilation.
    Why we should use switches to tell the compiler, "This is a Win32 code" or "This is a Win32 console code"?
    Learn C++ (C++ Books, C Books, FAQ, Forum Search)
    Code painter latest version on sourceforge DOWNLOAD NOW!
    Download FSB Data Integrity Tester.
    Siavosh K C

  7. #7
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    Location
    New York
    Posts
    1,465
    Do you want it to set up a console window for you or not?

  8. #8
    Registered User
    Join Date
    Apr 2003
    Posts
    2,662
    There is a C++ code.
    There is a C++ compiler.
    Then there should be a machine code after compilation.
    Why we should use switches to tell the compiler, "This is a Win32 code" or "This is a Win32 console code"?
    Presumably, so windows knows what to do with the code. As far as I know, that's the way windows was designed, so you have to use the interfaces provided by the designers of the software.

  9. #9
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,006
    Quote Originally Posted by siavoshkc
    Why we should use switches to tell the compiler, "This is a Win32 code" or "This is a Win32 console code"?
    Entry point might be one reason. Should the linker look for main or WinMain?

    [edit]
    Why should the compiler know the target environment?
    Every translator should know into what language to translate.
    Last edited by Dave_Sinkula; 03-12-2006 at 08:45 PM.
    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.*

  10. #10
    System Novice siavoshkc's Avatar
    Join Date
    Jan 2006
    Location
    Tehran
    Posts
    1,231
    Entry point might be one reason. Should the linker look for main or WinMain?
    I thought that main() is the standard entery of all programs in C/C++ language. But it seems that it is not the case in Windows compiler, am I right?

    Now I make a question that I think it's answer will be the answer of my first question. How can we write a Win32 code, WITHOUT using corresponding switches.
    Learn C++ (C++ Books, C Books, FAQ, Forum Search)
    Code painter latest version on sourceforge DOWNLOAD NOW!
    Download FSB Data Integrity Tester.
    Siavosh K C

  11. #11
    System Novice siavoshkc's Avatar
    Join Date
    Jan 2006
    Location
    Tehran
    Posts
    1,231
    It is not a Windows programming question I think. But it is OK.
    Learn C++ (C++ Books, C Books, FAQ, Forum Search)
    Code painter latest version on sourceforge DOWNLOAD NOW!
    Download FSB Data Integrity Tester.
    Siavosh K C

  12. #12
    System Novice siavoshkc's Avatar
    Join Date
    Jan 2006
    Location
    Tehran
    Posts
    1,231
    I think I solved my problem. This is linker that should know the entery point of program not the compiler and that switches are for linker not the compiler. Thanks for replies, happy to see more.
    Learn C++ (C++ Books, C Books, FAQ, Forum Search)
    Code painter latest version on sourceforge DOWNLOAD NOW!
    Download FSB Data Integrity Tester.
    Siavosh K C

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. another do while question
    By kbpsu in forum C++ Programming
    Replies: 3
    Last Post: 03-23-2009, 12:14 PM
  2. Compile question?
    By tomy in forum C++ Programming
    Replies: 6
    Last Post: 04-11-2008, 05:33 AM
  3. Design layer question
    By mdoland in forum C# Programming
    Replies: 0
    Last Post: 10-19-2007, 04:22 AM
  4. opengl DC question
    By SAMSAM in forum Game Programming
    Replies: 6
    Last Post: 02-26-2003, 08:22 PM
  5. Very simple question, problem in my Code.
    By Vber in forum C Programming
    Replies: 7
    Last Post: 11-16-2002, 02:57 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21