warning C4005: 'DLLIMPEXP' : macro redefinition ???

warning C4005: 'DLLIMPEXP' : macro redefinition ???

Anonymous
Not applicable
1,382 Views
10 Replies
Message 1 of 11

warning C4005: 'DLLIMPEXP' : macro redefinition ???

Anonymous
Not applicable
Hi,

Would someone know why I am getting the following warning: "warning C4005: 'DLLIMPEXP' : macro redefinition". I have a ARX project and a DBX project. But when I added a custom object to the DBX this warning appeared. Everything appears to run correctly. But I must be doing something wrong.

The wizard generated code in the ARX is redefining DLLIMPEXP from the DBX.

{code}
#ifdef TOOLARX_MODULE
#define DLLIMPEXP __declspec(dllexport)
#else
//----- Note: we don't use __declspec(dllimport) here, because of the
//----- "local vtable" problem with msvc. If you use __declspec(dllimport),
// ...
//----- memory indefinitely, there is no problem with vtables unexpectedly
//----- going away.
#define DLLIMPEXP
#endif
{code}

{code}
#ifdef TOOLDBX_MODULE
#define DLLIMPEXP __declspec(dllexport)
#else
//----- Note: we don't use __declspec(dllimport) here, because of the
//----- "local vtable" problem with msvc. If you use __declspec(dllimport),
// ...
//----- memory indefinitely, there is no problem with vtables unexpectedly
//----- going away.
#define DLLIMPEXP
#endif
{code}

I am not sure of how the generated code is meant to work so I am not sure how I should fix it.
Could anyone point me in the right direction?

Thank you

Joseph
0 Likes
1,383 Views
10 Replies
Replies (10)
Message 2 of 11

Anonymous
Not applicable
In a given project, either TOOLARX_MODULE or TOOLDBX_MODULE should be
defined, never both. The error indicates that both are defined.
--
Owen Wengerd
President, ManuSoft <>
VP Americas, CADLock, Inc. <>


"Joseph_L" wrote in message news:6278290@discussion.autodesk.com...
> Hi,
>
> Would someone know why I am getting the following warning: "warning C4005:
> 'DLLIMPEXP' : macro redefinition". I have a ARX project and a DBX project.
> But when I added a custom object to the DBX this warning appeared.
> Everything appears to run correctly. But I must be doing something wrong.
> [...]
0 Likes
Message 3 of 11

Anonymous
Not applicable
Thank you Owen,

I have been checking out what you said. I see that both TOOLARX_MODULE and TOOLDBX_MODULE are defined in the preprocessor definitions.

I removed the TOOLARX_MODULE definition and it compiled without any warnings but then the program crashed when it hit the acdbTransactionManager->startTransaction() command. This code is in the ARX project. (should it be in the DBX project?)

I also tried removing the TOOLDBX_MODULE definition but this resulted in a lot of linker errors so I am thinking that this is not the correct thing to do.

Which one is meant to be defined? Am I supposed to run all database transactions from the DBX project?

In previous plugins I had both the ARX_MODULE and DBX_MODULE defined and I preformed the transactions through the ARX project and it worked ok. (You understand this is all a steep learning curve for me!)

Thank you!

Regards

Joseph
0 Likes
Message 4 of 11

Anonymous
Not applicable
> Which one is meant to be defined? Am I supposed to run all database
> transactions from the DBX project?

The ARX project should have TOOLARX_MODULE defined, and the DBX project
should have TOOLDBX_MODULE defined. You can call acdb functions from either
module; you just can't call non-acdb functions from the DBX module. You
might be best served to start over and let the wizard generate both projects
for you.
--
Owen Wengerd
President, ManuSoft <>
VP Americas, CADLock, Inc. <>
0 Likes
Message 5 of 11

Anonymous
Not applicable
Owen,

Thank you for the reply!

I have been looking further into this issue. I created a new solution as you suggested but the problem was reproduced.

To explain briefly what I did: I made a ARX module and created in that a Transaction reactor and then I made a DBX module and created a custom object in that. So far so good. If you compile this there is no warnings or errors. But when I include the custom object header file in any one of the header files of the ARX I get this macro redefinition warning. If I only include it in the .cpp files, no problems. but this is no good to me because I use the custom object in a header file. I also just tried to predeclare the custom object class but it was not good enough either as I declare a custom object in an ARX class, and I therefore get a "uses undefined class" error.

I suppose I could use a pointer to the custom object in my ARX class and I imagine this would then work. But I think my problem is that I am not including the DBX module correctly in the ARX. Can I include the DBX custom object in the header of an ARX file? And if so how? I looked through the samples and they only include it in the .cpp file.

Thank you again.

Joseph
0 Likes
Message 6 of 11

Anonymous
Not applicable
Joseph:

I decided to test, so I created an ARX and DBX project with the wizard,
added a custom object to the DBX and a class to the ARX, then included the
custom object's header file in the ARX class' header file. As expected,
this builds with no errors. I used ObjectARX 2010 with the latest version
of the wizard.
--
Owen Wengerd
President, ManuSoft <>
VP Americas, CADLock, Inc. <>


"Joseph_L" wrote in message news:6282968@discussion.autodesk.com...
> Owen,
>
> Thank you for the reply!
>
> I have been looking further into this issue. I created a new solution as
> you suggested but the problem was reproduced.
>
> To explain briefly what I did: I made a ARX module and created in that a
> Transaction reactor and then I made a DBX module and created a custom
> object in that. So far so good. If you compile this there is no warnings
> or errors. But when I include the custom object header file in any one of
> the header files of the ARX I get this macro redefinition warning. If I
> only include it in the .cpp files, no problems. but this is no good to me
> because I use the custom object in a header file. I also just tried to
> predeclare the custom object class but it was not good enough either as I
> declare a custom object in an ARX class, and I therefore get a "uses
> undefined class" error.
>
> I suppose I could use a pointer to the custom object in my ARX class and I
> imagine this would then work. But I think my problem is that I am not
> including the DBX module correctly in the ARX. Can I include the DBX
> custom object in the header of an ARX file? And if so how? I looked
> through the samples and they only include it in the .cpp file.
>
> Thank you again.
>
> Joseph
0 Likes
Message 7 of 11

Anonymous
Not applicable
Owen,

That is interesting! So it would seem that something is wrong with my configuration / wizard. Well one difference is that I am working in AutoCAD 2009 / ObjectArx 2009. But I would imagine that this should work the same as 2010. ?

I believe I am using the latest wizard for 2009, I got it in January of this year.

Well, I much appreciate your comments. At least I know that it should work!

I'll make a follow up post if I can figure out what is causing this problem.

Thanks again.

Joseph
0 Likes
Message 8 of 11

Anonymous
Not applicable
It's possible that there was a bug in the 2009 wizard, but I'm not aware
of one that would cause this. I think the most likely explanation is that
you are doing something incorrectly, or at least unexpected, that causes it.
--
Owen Wengerd
President, ManuSoft <>
VP Americas, CADLock, Inc. <>


"Joseph_L" wrote in message news:6283480@discussion.autodesk.com...
> Owen,
>
> That is interesting! So it would seem that something is wrong with my
> configuration / wizard. Well one difference is that I am working in
> AutoCAD 2009 / ObjectArx 2009. But I would imagine that this should work
> the same as 2010. ?
>
> I believe I am using the latest wizard for 2009, I got it in January of
> this year.
>
> Well, I much appreciate your comments. At least I know that it should
> work!
>
> I'll make a follow up post if I can figure out what is causing this
> problem.
>
> Thanks again.
>
> Joseph
0 Likes
Message 9 of 11

cyrille_fauvel
Autodesk
Autodesk
Owen is correct. As far I understand the issue there is 2 projects TOOLARX and TOOLDBX which define exports. The TOOLARX project or a third project probably includes the TOOLDBX .h file which defines the DLLIMPEXP symbol, but since TOOLARX is not supposed to define the TOOLDBX_MODULE symbol, that should not cause any problem. If you are seeing that error, it means you have that symbol define in your project setting (or .h). Please remove it since the TOOLDBX_MODULE symbol should be present only in the TOOLDBX_MODULE project.

Cheers
cyrille
0 Likes
Message 10 of 11

Anonymous
Not applicable
Cyrille,

Thank you! Base on what you and Owen were saying I re-examined the setup. And I believe I figured out the problem. What threw me off is that both of you were saying that the TOOLDBX_MODULE should not be defined in the ARX module. But I did not have the TOOLDBX_MODULE defined in the ARX only in the DBX. The problem seems to be that the TOOLARX_MODULE was defined in the ARX module and then the DBX module was included in a header file of the ARX module. therefore this would cause the DLLIMPEXP to be redefined. I tried to remove the TOOLARX_MODULE definition from the preprocessor definitions before but the program would crash when it hit the acdbTransactionManager->startTransaction() command. I have since reworked my transactions and this time I get no problems.

Does this sound correct?

Thank you for all your help!

Regards

Joseph
0 Likes
Message 11 of 11

Anonymous
Not applicable
> Does this sound correct?

No. I think you should spend some time to understand what the DLLIMPEXP
macro does and how it is intended to work. Once you understand it, you
should be able to methodically track down the cause of your error without
resorting to speculation.
--
Owen Wengerd
President, ManuSoft <>
VP Americas, CADLock, Inc. <>
0 Likes