CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 19
  1. #1
    Join Date
    Dec 2009
    Posts
    2

    compile only one .cpp file???

    I'm fairly new to C++, so everything I do is with a single .cpp file. When I used the Bloodshed Dev C++ IDE, I was able to compile and run a single source file. I recently started using Visual C++ 2008 (express edition, if that matters) and now it seems like I can not compile a single file--I have to stick it inside a project in order to compile it. Is there a way around this? With Visual C++ can I compile a single .cpp file without using a "project"?

    Any help would be greatly appreciated. Thanks!

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: compile only one .cpp file???

    It doesn't make any sense IMHO, to compile a single file without any project.
    Victor Nijegorodov

  3. #3
    Join Date
    Oct 2008
    Location
    Cologne, Germany
    Posts
    756

    Re: compile only one .cpp file???

    Quote Originally Posted by VictorN View Post
    It doesn't make any sense IMHO, to compile a single file without any project.
    i'm sorry, but you're comment either... he didn't ask whether it makes sense but how to do it, so probalby it makes sense in his case

    @jdqie
    http://msdn.microsoft.com/en-us/library/ms235639.aspx
    win7 x86, VS 2008 & 2010, C++/CLI, C#, .NET 3.5 & 4.0, VB.NET, VBA... WPF is comming

    remeber to give feedback you think my response deserves recognition? perhaps you may want to click the Rate this post link/button and add to my reputation

    private lessons are not an option so please don't ask for help in private, I won't replay

    if you use Opera and you'd like to have the tab-button functionality for the texteditor take a look at my Opera Tab-UserScirpt; and if you know how to stop firefox from jumping to the next control when you hit tab let me know

  4. #4
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: compile only one .cpp file???

    Quote Originally Posted by memeloo View Post
    i'm sorry, but you're comment either... he didn't ask whether it makes sense but how to do it, so probalby it makes sense in his case

    @jdqie
    http://msdn.microsoft.com/en-us/library/ms235639.aspx
    Well, it is interesting info (and, probably, will be useful for OP)!

    As for me - I don't like using command prompt when I can use VS IDE with all its features as debugging, break points, watch, output and other windows and so on.
    Victor Nijegorodov

  5. #5
    Join Date
    Apr 2009
    Location
    Cochin
    Posts
    83

    Thumbs up Re: compile only one .cpp file???

    As for me - I don't like using command prompt when I can use VS IDE with all its features as debugging, break points, watch, output and other windows and so on
    ++i
    "I studied everything but never topped. Today, toppers of the world's best universities are my employees"

    -William Henry Gates (Bill Gates)

  6. #6
    Join Date
    Oct 2008
    Location
    Cologne, Germany
    Posts
    756

    Re: compile only one .cpp file???

    i = (isEasier == true ? i-1 : i+1)
    win7 x86, VS 2008 & 2010, C++/CLI, C#, .NET 3.5 & 4.0, VB.NET, VBA... WPF is comming

    remeber to give feedback you think my response deserves recognition? perhaps you may want to click the Rate this post link/button and add to my reputation

    private lessons are not an option so please don't ask for help in private, I won't replay

    if you use Opera and you'd like to have the tab-button functionality for the texteditor take a look at my Opera Tab-UserScirpt; and if you know how to stop firefox from jumping to the next control when you hit tab let me know

  7. #7
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: compile only one .cpp file???

    Quote Originally Posted by memeloo View Post
    i = (isEasier == true ? i-1 : i+1)
    I prefer:
    Code:
    if(isEasier)
         ++i;
    else
         --i;
    Victor Nijegorodov

  8. #8
    Join Date
    Jan 2006
    Location
    Singapore
    Posts
    6,765

    Re: compile only one .cpp file???

    How about:
    Code:
    const int increments[] = {1, -1};
    i += increments[isEasier];
    C + C++ Compiler: MinGW port of GCC
    Build + Version Control System: SCons + Bazaar

    Look up a C/C++ Reference and learn How To Ask Questions The Smart Way
    Kindly rate my posts if you found them useful

  9. #9
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: compile only one .cpp file???

    Quote Originally Posted by laserlight View Post
    How about:
    Code:
    const int increments[] = {1, -1};
    i += increments[isEasier];
    It won't work for bool isEasier, only for int for which only 0 and 1 are allowed...
    So it would be much more complicated to implement.
    Victor Nijegorodov

  10. #10
    Join Date
    Jan 2006
    Location
    Singapore
    Posts
    6,765

    Re: compile only one .cpp file???

    Quote Originally Posted by VictorN
    It won't work for bool isEasier, only for int for which only 0 and 1 are allowed...
    There exists an implicit conversion from bool to int whereby false is converted to 0 and true is converted to 1.
    C + C++ Compiler: MinGW port of GCC
    Build + Version Control System: SCons + Bazaar

    Look up a C/C++ Reference and learn How To Ask Questions The Smart Way
    Kindly rate my posts if you found them useful

  11. #11
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: compile only one .cpp file???

    Quote Originally Posted by laserlight View Post
    There exists an implicit conversion from bool to int whereby false is converted to 0 and true is converted to 1.
    Good to know it!
    Thank you!
    Victor Nijegorodov

  12. #12
    Join Date
    Oct 2008
    Location
    Cologne, Germany
    Posts
    756

    Re: compile only one .cpp file???

    Quote Originally Posted by laserlight View Post
    How about:
    Code:
    const int increments[] = {1, -1};
    i += increments[isEasier];
    nice

    another one:
    Code:
    i += 1 * (isEasier * -1);
    Last edited by memeloo; December 17th, 2009 at 10:20 AM.
    win7 x86, VS 2008 & 2010, C++/CLI, C#, .NET 3.5 & 4.0, VB.NET, VBA... WPF is comming

    remeber to give feedback you think my response deserves recognition? perhaps you may want to click the Rate this post link/button and add to my reputation

    private lessons are not an option so please don't ask for help in private, I won't replay

    if you use Opera and you'd like to have the tab-button functionality for the texteditor take a look at my Opera Tab-UserScirpt; and if you know how to stop firefox from jumping to the next control when you hit tab let me know

  13. #13
    Join Date
    Jan 2006
    Location
    Singapore
    Posts
    6,765

    Re: compile only one .cpp file???

    Quote Originally Posted by memeloo
    another one:
    That won't work: if isEasier is false, the expression evaluates to 0, not -1.

    But I realise that my hack has a similiar bug: the array elements should be swapped.

    Anyway, we could adapt your example:
    Code:
    i += isEasier * -2 + 1;
    C + C++ Compiler: MinGW port of GCC
    Build + Version Control System: SCons + Bazaar

    Look up a C/C++ Reference and learn How To Ask Questions The Smart Way
    Kindly rate my posts if you found them useful

  14. #14
    Join Date
    Oct 2008
    Location
    Cologne, Germany
    Posts
    756

    Re: compile only one .cpp file???

    Quote Originally Posted by laserlight View Post
    That won't work: if isEasier is false, the expression evaluates to 0, not -1.
    ****! how could i not see it :\
    win7 x86, VS 2008 & 2010, C++/CLI, C#, .NET 3.5 & 4.0, VB.NET, VBA... WPF is comming

    remeber to give feedback you think my response deserves recognition? perhaps you may want to click the Rate this post link/button and add to my reputation

    private lessons are not an option so please don't ask for help in private, I won't replay

    if you use Opera and you'd like to have the tab-button functionality for the texteditor take a look at my Opera Tab-UserScirpt; and if you know how to stop firefox from jumping to the next control when you hit tab let me know

  15. #15
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    4,626

    Re: compile only one .cpp file???

    i += !isEasier - isEasier;


    Probably the best one to make people scratch their heads twice figuring out what this does.

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured