C++Builder units need #pragma package(smart_init)

Hi,

I have just upgraded to the latest official release, 9.0.97.1245, and recreated the Interface unit with the new code.

There are a few things that are not working correctly. the first one I don’t know the reason:

I had this code:

FService = CoMyService::Create(BinMessage, RemoteServer);
But for some reason, the compiler doesn’t accept this, and I have to access the operator, for each object, to get the correct interface, i.e.:

FService = CoMyService::Create(BinMessage->operator _di_IROBinMessage(), RemoteServer->operator _di_IROTransportChannel());

This is a small issue at best, being that the workaround is so simple. The previous interface unit, though, worked without problems with the new RO-SDK version (just without rebuilding the unit). It doesn’t matter, but I’m using RAD Studio 10.1.

The second issue is bigger: the cpp units need, at the beginning, the #pragma package(smart_init) preprocessor directive for them to work fine. Without it the linker goes mad, complaining about a lot of strange stuff. Adding this solved the issue.

I remember modifying the old templates to add this (as IIRC they didn’t have them originally) but with the new code I don’t know where or how to change this. I don’t see anymore the templates (or maybe I haven’t looked hard enough, but they certainly aren’t were they used to be).

Any hints on how to solve this, and/or to raise a report number for this item (it’s important, so it shouldn’t get lost).

Thanks!

you can generate _ServerAccess unit it already contains that code:

_di_INewService __fastcall NewLibrary::TServerAccess::get__NewService()
{
	return CoNewService::Create(this->Message->operator _di_IROMessage(), this->Channel->operator _di_IROTransportChannel());
}

I’ll added #pragma package(smart_init) directive to _intf and _invk files.

we’ve put our codegen to github: GitHub - remobjects/ROCodeGen: The code generation logic for RemObjects Remoting SDK. . you need to have VS and Elements compiler for recompiling code.

Does that ROCodeGen is used too also for the IDE tools? The code generated by the ROServiceBuilder I can modify without problem. the one that it’s tricky is the one generated automatically when compiling, from RAD Studio.

both (IDE and SB) uses the same dll ( RemObjects.SDK.CodeGen4.dll ).
some trick is present - this library should be put into gac also

Ok, edited the post as now I see that the #pragma directive is correctly generated with the latest version, just not easily obvious (or where I’m used to see it). Thanks and sorry for the rant.