Visual Studio not rebuilding automatically



  • On 19/05/2013 at 18:38, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:   R14Studi 
    Platform:   Windows  ;   
    Language(s) :     C++  ;

    ---------
    Hi, this is about Visual Studio 2010 for those who use it.
    I have myself used VS 12 years now, for C#. And I am used to it automatically rebuilding all that needs a rebuild when I press F5 to run the app.

    I now have two CPP files I constantly edit. One is the "major" C++ file for my plugin. The other file contains a helper class with various common functions. Whereas the "main" file seems to always rebuild and changes I made always take effect, the other file needs an explicit "Rebuild" to reflect the last changes I have made in it.

    Is this a C++ specific thing? I have never experienced it before in C#. I also made several tests before I posted this topic, and yes, the other file does not rebuild automatically.
    BTW, it is part of the project, not excluded.
    I have linked it in like this:

    #include "plugincommon.cpp"
    

    -Ingvar



  • On 19/05/2013 at 19:09, xxxxxxxx wrote:

    You should NEVER include a .cpp file!  Only headers (.h or .hpp), ever.  That might explain your issues. Headers are for definitions and passing them to other classes (class files - cpp or h).  CPP files are for declaration of the methods and should be isolated as each one is compiled into an object file that is then linked into the final result.



  • On 20/05/2013 at 05:00, xxxxxxxx wrote:

    Ok 😊
    As you understand I am new to C++
    I did not know you could implement the code itself in the header files, I thought it was for forward declarations only. Because that is what I want, for classes who have very small simple functions, I saw no need to have a) header file b) cpp file just for this.
    For everyone else reading this and being in the same boat as I am, here is a very good article for us C++ beginners:
    http://www.cplusplus.com/forum/articles/10627/

    -Ingvar



  • On 20/05/2013 at 05:26, xxxxxxxx wrote:

    Originally posted by xxxxxxxx

    You should NEVER include a .cpp file!  Only headers (.h or .hpp), ever.

    Well, I must disagree and correct I guess.

    Especially if you have templated design you may very well include your .cpp file into the header file. Actually it is common practice doing so (and is absolutely valid considering C++ language standard).

    In the end it's just an implementation file as any other (some simply name them .inl or .impl or whatever by convention to avoid confusion) and therefore can be inline-included as necessary. It just has to make sense or be necessary.

    Considering the building issue, as Robert said this could be indeed the cause (though make sure you don't have the minimal rebuilding option turned off in the build settings...) and it's of course wise to use header files (don't be lazy) and implementation files for class definition and...well, implementation.



  • On 20/05/2013 at 08:14, xxxxxxxx wrote:

    > don't be lazy
    I want to be productive.
    Having programmed for many years, I have developed habits. And going from Object Pascal (Delphi) to C# was a relief, because I got rid of this interface clause, and could just write functions directly. And just employ the "using" declaration to include any cs file I need.

    I also wrote assembler those days, in cases where it was required to achieve certain tasks, or for pure speed purposes.
    For my kind of plugins, in 2013, speed has only one concern: Speeding up me when writing the plugin. I write plugins (they're called add-ins) for the Sony multimedia array of products, too. Sony Vegas (video) and Sony Sound Forge (sound). These apps are written in .Net. And writing add-ins for them is a breeze. Reflection and C# and Visual Studio - it is almost like the source code pops out of the screen and tell me what to do. I can write complicated stuff in a few hours, that just works. The SDK is self explanatory, and hovering over a function, a property - hints pop up telling me why, what and how.

    When this is said, I am glad I started with C++ for C4D. Thinking about all the time I spent struggling with Python, which I firstly HATE, and secondly has no debugging capabilities, and thirdly I have to use Eclipse..

    But for productivity - getting things done, nothing beats C#.

    Edited:
    I now use h files like I am used to in C#. That is - I declare classes, and write function implementations directly, on place. Doing this, changes immediately take effect, and all is fine. So the reason, the case of this thread, is solved and closed. Until C4D starts to melt down, I will use this approach..
    .. or someone gives me a good reason not to..
    -Ingvar



  • On 20/05/2013 at 08:42, xxxxxxxx wrote:

    Well, a good reason is simply that you increase your compiling time tremendously, everytime you change something in the member functions code. Not a good idea.

    Good code design helps in every aspect and that means, declarations go into h and implementation goes into ~cpp if possible.



  • On 20/05/2013 at 08:48, xxxxxxxx wrote:

    Ok, that is a good reason.
    And I now understand more how it works. I thought maybe the compiler / builder was smart enough to figer out what file has been changed and not since the last build. And just compile changed files, regardless. But I understand what you say.



  • On 20/05/2013 at 09:42, xxxxxxxx wrote:

    Originally posted by xxxxxxxx

    Originally posted by xxxxxxxx

    You should NEVER include a .cpp file!  Only headers (.h or .hpp), ever.

    Well, I must disagree and correct I guess.

    ...

    What I meant is that it appears that the .cpp file was both included and part of the build.  You can't do it that way.  It is safe to do one or the other but not both (maybe templates are handled by the compiler/linker a bit differently?).


Log in to reply