c++ static library dependencies, header including header -


So I'm working to upgrade the architecture of the application to a more modular design. This is a C ++ application that uses a built-in seamless C-library if we are building for a specific goal, otherwise it uses a separate library back-end

current In the application front-end code, the GUI code is directly linked to the intact C-library, which works on only one goal. What has been done is that the monolithic C-library has been put into "module", which exposes the common C ++ interface to the GUI part of the application for consumption. In this way we can change the target and can not change the GUI code. The pre-existing GUI code uses structures defined within the C-library, which is common to all possible C-libraries.

Inside the C ++ module I've defined the proxy type that looks like this:

  // ModuleTypes.hpp typedef CPP_TYPE C_LEGACY_TYPE;   

and the GUI code just uses the CPPTPEPE of the already existing C_LEGACY_TYPE.

In the module project elsewhere, the module HPP looks like this:

  // Module.hpp #include "C_LEGACY_TYPES.hpp" ... # "ModuleTypes.hpp"   

So when the C ++ module is compiled into a static Lib, the module module in HPP.HPP (hence the module typing.HPP before the CLEGACIHPESHPP is included) What is CTCLEPEP, And the static library is just fine.

The problem is in the GUI module, for example:

  // Gui1.hpp class Gui1 {zero method 1 (CPP_TYPE value); };   

Since the CPP_TYPE can not be declared further, at the top, I add "# ModuleTypes.hpp" to Gui1.hpp.

  // Gui1.hpp #include "ModuleTypes.hpp" class Gui1 {void Method1 (CPP_TYPE value); };   

When I go to compile the GUI module, then these errors occur because it can not detect what is the C_LEGACY_TYPE, the only way to solve it is to #ModuleTypes.hpp inside Include "C_LEGACY_TYPE.hpp". It goes to the GUI, however, where it is known that when the heritage C headers are compiled.

I like the GUI.hpp to include "ModuleTypes.hpp" #, but use definition from static library of C_LEGACY_TYPE, and "C_LEGACY_TYPES.h" inside "ModuleTypes.hpp" Do not involve.

I understand why the error is happening, I am looking for an alternative solution.

With architecture changes, we are migrating to C ++, when I have module modes for GUI module. Defines in HP. +11 So I'm open to any suggestion VC2010 is what we are making with.

You back-to-back library of a common interface layer (wrapper class), so that you can easily Can change the end of a few more later.

However, you also need to make sure that the type C Library used in the interface is treated as same as the wrapper class. Since your GUI layer needs to include the C_LEGACY_TYPE.hpp header file, I suspect that your type is not being isolated, as they should be.

This may mean that you should do some type of conversion within the wrapper class, know about the types used by the C library to replace with the types of GI. The wrapper class interface (i.e. the general interface) should not be specific to any type of back-end c library.

Comments

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -