User forums > Using Code::Blocks

Working with 2 versions of a library

(1/2) > >>

ote:
Hello,

I'm developing a plugin for a soft which has different versions and I need to make the plugin work for the 2 latest (say 1 and 2 for the simplicity). In order to do that, I've created 2 different build targets which have some difference in Project -> build options -> search directories -> compiler.

It works well, I can compile and execute my plugin for both versions, but when I'm developing and need to parse some headers files from the library provided by the soft, I haven't figure how to open the "good" header file depending on the current build target. What I would like, is when I'm working on the build target for version 1 and I have my curser on some types or variables and do search -> Goto Declaration, it opens the header from version 1 and the header of version 2 if I'm currently working on build target for version 2. Right now it works for the build target for version 1 (always opening header from version 1), but for the version 2, it is always opening the header from version 1, unless that class don't exist in version 1 (I have some #if #else #endif sections for some part of the code which needs different functions depending on the version, and by the way, is it possible to grey the irrelevant part of the code as I thought settings ->editor ->general settings -> other options -> interpret #if #else .. would do ?).

I was able to do that in eclipse with cdt, but the index was taking too much time to update every time I was switching from one build version to another, and it was really annoying. Is there a way to do that in C::B ?

I'm working with C::B Nightly build debugger branch SVN 7845

MortenMacFly:

--- Quote from: ote on February 28, 2012, 06:33:37 pm ---[...] when I'm working on the build target for version 1 and I have my curser on some types or variables and do search -> Goto Declaration, it opens the header from version 1 and the header of version 2 if I'm currently working on build target for version 2.[...]

--- End quote ---
You can achieve that if instead of using targets you split into projects and then use a CC parser for each project. The "target" concept is more for stuff belonging to one "software", what you have is actually 2 software (versions). You can bundle the projects again using a workspace. Dependencies (to arrange the build order) are possible within a WS, too.

ote:
Well creating 2 projects seems to be kind of hard to maintain to me. Every time I change something in one project (include, compiler option...), I have to do the same for the other project... And the class I'm coding is the same for the two projects except for a dozen of lines of code... So I add some modifications to the file in one project and had to do the same for the other. Or is there a way to have the same .cpp and .h files in two projects ?

Besides, I'm looking for a good long term solution as the new version hasn't been officially released yet (+ the time for my company to do the upgrade), and I'll have to develop for the two versions for at least 4/5 months.

Isn't there another way of doing what I want ?

stahta01:

--- Quote from: ote on February 29, 2012, 12:36:59 pm ---Or is there a way to have the same .cpp and .h files in two projects ?

--- End quote ---

Yes, you can you the same .cpp and .h files in two projects. You will need to use different target names to prevent the object files over writing each other. Or use some other method to keep the object files separate.

Tim S.

MortenMacFly:

--- Quote from: ote on February 29, 2012, 12:36:59 pm ---Isn't there another way of doing what I want ?

--- End quote ---
Another option is the use of global variables and build script(s). then, you can literally do whatever you want.

Navigation

[0] Message Index

[#] Next page

Go to full version