VC++ compile options

Discussion in 'C Programming' started by ashu, Feb 24, 2012.

  1. ashu

    ashu Guest

    Hi all,
    My question is about the syntax of the VC++project file. I have a set
    of files which make up the build and I wanted to apply O2 level
    optimization only on one file.
    Below is a snippet of the .vcxproj file.
    ****************************************************************
    <ItemGroup>
    <ClCompile Include="..\src\b_wrapper.c" />
    <ClCompile Include="..\src\assh.c" />
    <ClCompile Include="..\src\user_line.c" >
    <Optimization>/O2</Optimization>
    </ClCompile>
    </ItemGroup>
    ******************************************************************
    Is the syntax is correct and in that case, would it lead to O2 level
    optimization only on user_line.c file ?

    regards
    ashu
    ashu, Feb 24, 2012
    #1
    1. Advertising

  2. ashu

    Geoff Guest

    On Fri, 24 Feb 2012 08:46:52 -0800 (PST), ashu
    <> wrote:

    >Hi all,
    >My question is about the syntax of the VC++project file. I have a set
    >of files which make up the build and I wanted to apply O2 level
    >optimization only on one file.
    >Below is a snippet of the .vcxproj file.
    >****************************************************************
    > <ItemGroup>
    > <ClCompile Include="..\src\b_wrapper.c" />
    > <ClCompile Include="..\src\assh.c" />
    > <ClCompile Include="..\src\user_line.c" >
    > <Optimization>/O2</Optimization>
    > </ClCompile>
    > </ItemGroup>
    >******************************************************************
    >Is the syntax is correct and in that case, would it lead to O2 level
    >optimization only on user_line.c file ?
    >
    >regards
    >ashu


    This is off-topic for this group.

    However, why are you poking at the project file manually? VC++ IDE
    allows you to set per-file optimization settings. Use the Project
    Explorer and right-click the source file, then edit properties for
    that file.

    NOTE: VC++ turns off optimizations in Debug build and sets -O2 on
    Release builds across the entire project by default.
    Geoff, Feb 24, 2012
    #2
    1. Advertising

  3. On Feb 24, 4:46 pm, ashu <> wrote:
    >
    > Is the syntax is correct and in that case, would it lead to O2 level
    > optimization only on user_line.c file ?
    >

    Unlikely. It's not well-formed xml as the structure would suggest what
    you suppose, but most compilers will compile several C source files on
    one invocation, keeping the same settings. However the only real way
    to find out is to ask VC++ technical support, and even they will
    probably have to root around for the answer. Or you could set up a
    test file if the optimiser defines a symbol to the preprocessor.
    --
    Basic Algorithms - a second book of C. Read it after you've finished
    your primer.
    http://www.malcolmmclean.site11.com/www
    Malcolm McLean, Feb 25, 2012
    #3
  4. ashu

    Geoff Guest

    On Fri, 24 Feb 2012 08:46:52 -0800 (PST), ashu
    <> wrote:

    >Hi all,
    >My question is about the syntax of the VC++project file. I have a set
    >of files which make up the build and I wanted to apply O2 level
    >optimization only on one file.
    >Below is a snippet of the .vcxproj file.
    >****************************************************************
    > <ItemGroup>
    > <ClCompile Include="..\src\b_wrapper.c" />
    > <ClCompile Include="..\src\assh.c" />
    > <ClCompile Include="..\src\user_line.c" >
    > <Optimization>/O2</Optimization>
    > </ClCompile>
    > </ItemGroup>
    >******************************************************************
    >Is the syntax is correct and in that case, would it lead to O2 level
    >optimization only on user_line.c file ?
    >
    >regards
    >ashu


    I selected a single source file within a project with Project Explorer
    and it did this:

    <ClCompile Include="g_misc.c">
    <PreprocessorDefinitions
    Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
    <PreprocessorDefinitions
    Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
    <Optimization
    Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">MaxSpeed</Optimization>
    </ClCompile>
    Geoff, Feb 26, 2012
    #4
  5. > My question is about the syntax of the VC++project file. I have a set
    > of files which make up the build and I wanted to apply O2 level
    > optimization only on one file.
    > Below is a snippet of the .vcxproj file.


    Shouldn't you use a make file if you wanna do things command-line?

    --
    @~@ You have the right to remain silence.
    / v \ Simplicity is Beauty! May the Force and farces be with you!
    /( _ )\ (Fedora 15 i686) Linux 3.2.6
    ^ ^ 15:41:01 up 9 days 2:38 0 users load average: 0.00 0.01 0.05
    ä¸å€Ÿè²¸! ä¸è©é¨™! ä¸æ´äº¤! ä¸æ‰“交! ä¸æ‰“劫! ä¸è‡ªæ®º! è«‹è€ƒæ…®ç¶œæ´ (CSSA):
    http://www.swd.gov.hk/tc/index/site_pubsvc/page_socsecu/sub_addressesa
    Man-wai Chang, Mar 4, 2012
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Cliff  Martin
    Replies:
    1
    Views:
    3,034
    Larry Smith
    Jan 31, 2007
  2. Nagaraj
    Replies:
    1
    Views:
    856
    Lionel B
    Mar 1, 2007
  3. jacksu
    Replies:
    0
    Views:
    507
    jacksu
    Oct 9, 2007
  4. Utkado
    Replies:
    2
    Views:
    2,100
  5. Bryan Richardson
    Replies:
    6
    Views:
    284
    Bryan Richardson
    Feb 25, 2008
Loading...

Share This Page