VC8 et Stingray: DLL

OmniXXX Messages postés 2 Date d'inscription vendredi 5 octobre 2007 Statut Membre Dernière intervention 5 octobre 2007 - 5 oct. 2007 à 16:18
OmniXXX Messages postés 2 Date d'inscription vendredi 5 octobre 2007 Statut Membre Dernière intervention 5 octobre 2007 - 5 oct. 2007 à 17:01
Desole de l'anglais mais je ne veux pas reecrire toute ma question
-------------------

Alright, this is not code oriented and so I'll make it brieft:

Sorry don't know how to add code in this forum yet (rather new)

A class like this:

#ifndef VXT_SIMPLE_BUTTON_SPEC
#ifdef VXT_UIUTILS_DLL
#define VXT_SIMPLE_BUTTON_SPEC __declspec(dllexport)
#else
#define VXT_SIMPLE_BUTTON_SPEC __declspec(dllimport)
#endif
#endif

class VXT_SIMPLE_BUTTON_SPEC vxtUISimpleButton: public CGXStatic


the inherited class is FROM stingray and is now using dll interface compared to previous release like so:

#ifdef _GXDLL
#ifdef _GXDLL_IMPL
#define GRID_API __declspec( dllexport )
// #pragma message("GRID_API: dllexport")
#else
#define GRID_API __declspec( dllimport )
// #pragma message("GRID_API: dllimport")
#endif
#else // !_GXDLL
#define GRID_API
#endif


class CGXStatic : public CGXControl
{
DECLARE_CONTROL(CGXStatic)

// Construction
public:
// Constructor & Destructor
GRID_API CGXStatic(CGXGridCore* pGrid);

GRID_API virtual CRect GetCellRect(ROWCOL nRow, ROWCOL nCol, LPRECT rectItem NULL, const CGXStyle* pStyle NULL);
// compute the interior rectangle for the text
// without buttons and borders
GRID_API virtual CSize AddBorders(CSize size, const CGXStyle& style); // counterpart to GetCellRect

GRID_API virtual CSize CalcSize(CDC* pDC, ROWCOL nRow, ROWCOL nCol, const CGXStyle& style, const CGXStyle* pStandardStyle, BOOL bVert);

GRID_API virtual BOOL CanFloatCell(ROWCOL nRow, ROWCOL nCol, const CGXStyle& style, BOOL bFloatOrFlood);

GRID_API virtual void Draw(CDC* pDC, CRect rect, ROWCOL nRow, ROWCOL nCol, const CGXStyle& style, const CGXStyle* pStandardStyle);

// cells tips enable
GRID_API void ImplementCellTips();
};


Now this returns:
error C2487: member of dll interface class may not be declared with dll interface
When using the macro:
#define DECLARE_CONTROL(class_name) \
protected: \
GRID_API static CGXControlClass* PASCAL _GetControlBaseClass(); \
public: \
static GX_DATA CGXControlClass ctrl##class_name; \
GRID_API virtual CGXControlClass* GetControlClass() const; \

#define IMPLEMENT_CONTROL(class_name, base_class_name) \
CGXControlClass* PASCAL class_name::_GetControlBaseClass() \
{ return CONTROL_CLASS(base_class_name); } \
GX_DATADEF CGXControlClass class_name::ctrl##class_name = { \
#class_name, &class_name::_GetControlBaseClass }; \
CGXControlClass* class_name::GetControlClass() const \
{ return &class_name::ctrl##class_name; } \

DECLARE_CONTROL(vxtUISimpleButton)


So I tried not using dllimport ON the class but instead on every functions

Which returned this:
warning C4273 : inconsistent dll linkage

on the macro:

#define IMPLEMENT_CONTROL(class_name, base_class_name) \
CGXControlClass* PASCAL class_name::_GetControlBaseClass() \
{ return CONTROL_CLASS(base_class_name); } \
GX_DATADEF CGXControlClass class_name::ctrl##class_name = { \
#class_name, &class_name::_GetControlBaseClass }; \
CGXControlClass* class_name::GetControlClass() const \
{ return &class_name::ctrl##class_name; } \

IMPLEMENT_CONTROL(vxtUISimpleButton, CGXStatic)

Which is present because (I think) that we defined this function:

virtual VXT_SIMPLE_BUTTON_SPEC vxtVoid Draw(CDC* pDC, CRect rect, ROWCOL nRow, ROWCOL nCol, const CGXStyle& style, const CGXStyle* pStandardStyle);

and the stingray class defined it this way:

GRID_API virtual void Draw(CDC* pDC, CRect rect, ROWCOL nRow, ROWCOL nCol, const CGXStyle& style, const CGXStyle* pStandardStyle);

Both are on dllImport

Any suggestion on how to "cleanly" remove the error and warning?

2 réponses

cs_juju12 Messages postés 966 Date d'inscription samedi 3 avril 2004 Statut Membre Dernière intervention 4 mars 2010 4
5 oct. 2007 à 16:52
Je pense que c'est parce que ta classe (vxtUISimpleButton) est déclarée dllexport (ou import j'en sais rien) via VXT_SIMPLE_BUTTON_SPEC, le problème c'est qu'avec ta macro DECLARE_CONTROL tu déclares des fonctions membres de cette classe également dllexport(resp. import), ce qui est interdit. Solution : enlève tous les GRID_API dans l'implémentation de ta macro (je vois pas pourquoi ca y était en fait).
0
OmniXXX Messages postés 2 Date d'inscription vendredi 5 octobre 2007 Statut Membre Dernière intervention 5 octobre 2007
5 oct. 2007 à 17:01
Le probleme est que la partie GRID_API viens du programme Stingray et changer cela pourrait degringolet ailleur car ce programme est assez volumineux...

Tout ce que je peux changer est ma classe vxt...le reste je ne peux y toucher sans causer des bugs externes
0
Rejoignez-nous