Thread: multiproject approach

  1. #1
    Registered User
    Join Date
    May 2006
    Posts
    630

    multiproject approach

    Hello..

    So I'm working on solution that has 2 projects (2 applications).
    A few source files are being used by both applications.
    One file is almost identical, except a few lines should be changed (boost::shared_from_this() instead of this; )

    for instance:

    for project 1 I need:
    Code:
    return this;
    project 2 needs:
    Code:
    return shared_from_this();
    Is this the right approach to put macro in front of this like:
    Code:
    #ifdef IS_MACRO_RETURN_THIS
    return this;
    #else
    return shared_from_this();
    #endif
    Is this the right way to solve that kind of problems?
    I havent faced with anything similar so far..

    If so, where should I #define IS_MACRO_RETURN_THIS ? On top of main .cpp file?
    If not, what would be the right way?

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    It sounds like potential maintenance trouble to me. Wouldn't it be better to factor out the common code, and then implement for each project using that common base?
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    you can define it in the project properties
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how would i approach this problem?
    By Huskar in forum C Programming
    Replies: 7
    Last Post: 03-30-2009, 06:36 AM
  2. Unsure on how to approach this concurrency problem
    By osiris^ in forum C# Programming
    Replies: 3
    Last Post: 04-29-2008, 11:47 PM
  3. Best approach
    By DV64h in forum Networking/Device Communication
    Replies: 6
    Last Post: 12-10-2006, 03:24 PM
  4. Angle of approach for C++
    By mepaco in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 12-13-2002, 07:08 PM
  5. software development approach...
    By dkt in forum A Brief History of Cprogramming.com
    Replies: 6
    Last Post: 10-16-2001, 09:15 PM