PrepAway - Latest Free Exam Questions & Answers

Which code segment should you use?

You are developing an application that will process orders. The debug and release versions of the
application will display different logo images.
You need to ensure that the correct image path is set based on the build configuration.
Which code segment should you use?

PrepAway - Latest Free Exam Questions & Answers

A.
Option A

B.
Option B

C.
Option C

D.
Option D

Explanation:
There is no such constraint (unless you define one explicitly) RELEASE.
http://stackoverflow.com/questions/507704/will-if-release-work-like-if-debug-does-in-c

5 Comments on “Which code segment should you use?

  1. Lord Vader says:

    The important part here is what DEBUG really is, and it’s a kind of constant defined that the compiler can check against.

    If you check the project properties, under the Build tab, you’ll find three things:

    A text box labelled “Conditional compilation symbols”
    A check box labelled “Define DEBUG constant”
    A check box labelled “Define TRACE constant”
    There is no such checkbox, nor constant/symbol pre-defined that has the name RELEASE.

    However, you can easily add that name to the text box labelled Conditional compilation symbols, but make sure you set the project configuration to Release-mode before doing so, as these settings are per configuration.

    So basically, unless you add that to the text box, #if RELEASE won’t produce any code under any configuration.

    https://msdn.microsoft.com/en-us/library/ew2hz0yd.aspx
    each #if directive in a source file must be matched by a closing #endif directive. Any number of #elif directives can appear between the #if and #endif directives, but at most one #else directive is allowed. The #else directive, if present, must be the last directive before #endif.
    The #if, #elif, #else, and #endif directives can nest in the text portions of other #if directives. Each nested #else, #elif, or #endif directive belongs to the closest preceding #if directive.
    If all occurrences of constant-expression are false, or if no #elif directives appear, the preprocessor selects the text block after the #else clause. If the #else clause is omitted and all instances of constant-expression in the #if block are false, no text block is selected.




    2



    0

Leave a Reply