Thread: Compiled If Statement

  1. #1
    Registered User
    Join Date
    May 2002
    Posts
    17

    Compiled If Statement

    which is faster, better, compiles into better code and such...

    Code:
    bool function()
    {
    if (something) return true;
    return false;
    {
    
    or...
    
    bool function()
    {
    if (something) return true;
    else return false;
    }

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Why not get your compiler to show the assembler it produces for this code?

    The difference will either be non-existant, or so small to be of no practical interest.

    The rest is just style IMO

    Besides
    Code:
    bool function ( ) {
        return something;
    }
    Just evaluates the boolean expression and returns it's result

  3. #3
    Registered User
    Join Date
    May 2002
    Posts
    17
    Youre right, the difference is completely insignificant
    but I was just wondering

    and out of curiosity, how do i make my compiler spit out ASM(thats MSVC++ for me).

    i learned ASM on my TI-83+ graphing calculator, and id be interested in learning something about it on a computer.

  4. #4
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    Originally posted by phatslug

    and out of curiosity, how do i make my compiler spit out ASM(thats MSVC++ for me).
    project->settings->c++->category->listing files->Listing file type->assembly with source code

  5. #5
    Unregistered
    Guest

    Question

    when has the the bool data type become legal in C??

    Mr. C

  6. #6
    Unregistered
    Guest

    Lightbulb

    Sorry, this is C++ not C. My mistake

    Mr. C.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Usefulness of the "else if" statement
    By gn17 in forum C Programming
    Replies: 7
    Last Post: 08-12-2007, 05:19 AM
  2. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  3. Meaning of this statement?
    By @nthony in forum C Programming
    Replies: 7
    Last Post: 07-16-2006, 02:57 AM
  4. Operator overloading in template classes
    By moejams in forum C++ Programming
    Replies: 5
    Last Post: 07-21-2003, 05:16 PM
  5. Uh-oh! I am having a major switch problem!
    By goodn in forum C Programming
    Replies: 4
    Last Post: 11-01-2001, 04:49 PM