Comments (8)
Could it be that the entire class is being optimized out when it is within the subModule, but not when it is within Main.exe? As moving RuntimeObject01 from SubModule to Main.exe resolves this.
This sounds very plausible - though I see this as a bug in the linker since the static constructor has a side effect, however I see a similar issue online:
https://social.msdn.microsoft.com/Forums/vstudio/en-US/5c5ee89d-2a38-483d-8550-484550901170/issues-with-static-variables-in-static-libraries?forum=vclanguage
It looks like you may need to use: #pragma comment(linker, "/include:SymbolToUse")
where SymbolToUse
is your class. When I get time I'll take a look to see if there is a way to add this to the REGISTER* macros when needed.
from runtimecompiledcplusplus.
If the library and your main executable are both linked against the same version of the RuntimeObjectSystem library then the class registration via PerModuleInterface::GetInstance()->AddConstructor( this ) should register the class visible to code in Main.exe.
Perhaps place a break point on that line to see what happens?
from runtimecompiledcplusplus.
Same RuntimeObjectSystem lib is linked to both the static lib and Main.exe.
Tested using both #pragma comment(lib,"RuntimeObjectSystem.lib")
and manually via project settings.
PerModuleInterface::GetInstance()->AddConstructor( this )
Only fires for any runtime classes within the Main.exe and any classes that have the REGISTERSINGLETON
macro outside of its own class.
ie.
#myClass.cpp (created outside of the RuntimeObjectSystem)
REGISTERSINGLETON(InterfaceLink, true);
causes the expected result of
0x023b4a08 {client.exe!TObjectConstructorConcrete<TActual<InterfaceLink>> TActual<InterfaceLink>::m_Constructor} {...}
However still doesn't discover classes that self delclare the macro within the static lib
ie.
RawInputI.h pure virtual
class RawInputI : public IObject
RawInput.h class RawInput : public TInterface<ID_RCPP_INPUT, RawInputI>
RawInput.cpp #include "ObjectInterfacePerModule.h" REGISTERSINGLETON(RawInput, true);
from runtimecompiledcplusplus.
any classes that have the REGISTERSINGLETON macro outside of its own class.
I don't quite understand what you mean by this.
A work around so far has been to place the REGISTERSINGLETON/REGISTERCLASS macro within another file that isn't loaded via RunTimeObjectSystem but this obviously isn't ideal.
Reading your first comment I'm also not sure I understand what you mean by this either.
In a few days I will have some time and I'll take a look at creating a small example project to see if I can replicate this.
from runtimecompiledcplusplus.
Reading your first comment I'm also not sure I understand what you mean by this either.
If I take the base example class RuntimeObject01.cpp the REGISTERCLASS
macro is defined within the .cpp file of its own class.
Doing this when the class is within the SubModule(static lib) it isn't discovered.
However if I remove the macro from RuntimeObject01
and place it in another cpp that is already used ie some initalization file for the subModule
. It runs as expected and RuntimeObjectSystem is able to discover it.
//Initalization.cpp
REGISTERSINGLETON(SubModuleClass0, true); //<- all loaded and visible as constructors within RuntimeObjectSystem
REGISTERCLASS(SubModuleClass1);
REGISTERCLASS(SubModuleClass2);
Initalization() // <- This class is constructed normally outside of the RuntimeObjectSystem
{
...
}
Could it be that the entire class is being optimized out when it is within the subModule, but not when it is within Main.exe? As moving RuntimeObject01 from SubModule
to Main.exe
resolves this.
Hopefully that clears it up a bit and thanks for the help thus far
from runtimecompiledcplusplus.
#pragma comment(linker, "/include:SymbolToUse")
does indeed fix the issue. Seems the linker throws out anything that isn't linked by the main executable. Only snag is the symbol
has to be the mangled/decorated name - to which I've been unable to find a flexible solution. __FUNCDNAME__
is close but has to be within the constructor.
from runtimecompiledcplusplus.
If any function which references the constructor is included, then I think this should force the constructor and the registered class to be included in linking.
A quick test of this would be to modify the REGISTERBASE
macro so that the definitions of GetTypeNameStatic
become:
template<> const char* TActual< T >::GetTypeNameStatic() { return #T; \
__pragma( comment(linker, "/include:" __FUNCDNAME__) ) \
} \
This is MS Specific and I should add macro around this, but for testing this might work.
I'm still busy with some things I need to finish asap, but hopefully can take a look at this in a few days.
EDIT: fixed syntax of pragma comment
from runtimecompiledcplusplus.
I can't yet find a simple generic way to force the linker to always compile & link a runtime compiled class which is in a static library.
The only approach which appears to work is to ensure the definition of the class' constructor is in a header, and that this is included by the main project, and that this has #pragma comment(linker, "/include:" __FUNCDNAME__ )
.
from runtimecompiledcplusplus.
Related Issues (20)
- Webpage moved HOT 1
- Crash in ObjectFactorySystem.cpp line 250 when no RCC++ objects and no logger
- Visual Studio 2019 debug info issue after first recompile
- Question: Use Case: Self-optimization HOT 6
- Remove need for hierarchy of classes with virtual functions in RuntimeTracking
- RUNTIME_COMPILER_SOURCEDEPENDENCY off-by-1 error HOT 2
- Improve FindFile handling of relative file paths
- Stack Cookie Check Failure error HOT 1
- Dynamic loading of generated code without writing to files HOT 2
- Linking compile output back into project HOT 3
- Getting Log: ObjectFactorySystem::AddConstructors() called with no constructors HOT 3
- Simplify RuntimeCompiledCPlusPlus by loading .dll's in RAM HOT 1
- Games HOT 1
- Runtime Linker issues HOT 7
- Deriving RCCpp Compilation HOT 4
- Runtime Compiled C++ Linker Errors HOT 2
- _kbhit on the linux HOT 1
- Code or executable in directories with non-ascii characters breaks RCC++
- Compiling many files on Windows may exceed maximum line length of compile command line
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from runtimecompiledcplusplus.