Hey guys,
When using an importcpp type in nim, like for example inside of seq[ptr FProperty] Nim will create a type definition for it in a std_sequtils like so:
struct tySequence__bf9bej5tmhu1mP9cYV1b81kw_Content { NI cap; FProperty* data[SEQ_DECL_SIZE];};
And it will put what's in the header pragma at the top, like so:
#include "nimbase.h"
#include "Definitions.NimForUEBindings.h"
#include "UEDeps.h"
The problem is that it adds it below nimbase.h and that causes conflict on Windows with the Unreal headers. For the rest of the files (non std) we just use emit /INCLUDESECTION/ which results on:
/*INCLUDESECTION*/
#include "Definitions.NimForUEBindings.h"
#include "UEDeps.h"
#include "nimbase.h"
So the question is, is it possible to use emit on the std? or there is something like INCLUDESECTION for the header pragma? Or any other workaround that allows to alter the order or even if nimbase is emitted at all for certain files?
Thanks,
Juan
The problem is that it adds it below nimbase.h and that causes conflict on Windows with the Unreal headers.
Which conflicts? I think the real solution here is to make nimbase.h play nicely.
There are a lot, not sure if making it to play nicely would be the way to go because maybe it has more to do with how Unreal does things. i.e. it elevates a lot of warning to be errors
Below is the error output, where it starts TCHAR (wchar_t) it seems that at some point in one of the includes of nimbase.h is sets it and makes Unreal to take two different paths on their macros
C:\Program Files\Epic Games\UE_5.0\Engine\Source\Runtime\Core\Public\HAL/Platform.h(1008): error C2371: 'TCHAR': redefinition; different basic types
C:\Program Files (x86)\Windows Kits\10\\include\10.0.19041.0\\um\winnt.h(594): note: see declaration of 'TCHAR'
C:\Program Files\Epic Games\UE_5.0\Engine\Source\Runtime\Core\Public\HAL/Platform.h(1054): error C2338: TCHAR size must be 2 bytes.
C:\Program Files\Epic Games\UE_5.0\Engine\Source\Runtime\Core\Public\GenericPlatform/GenericPlatformMisc.h(769): error C2535: 'void FGenericPlatformMisc::BeginNamedEvent(const FColor &,const TCHAR *)': member function already defined or declared
C:\Program Files\Epic Games\UE_5.0\Engine\Source\Runtime\Core\Public\GenericPlatform/GenericPlatformMisc.h(768): note: see declaration of 'FGenericPlatformMisc::BeginNamedEvent'
C:\Program Files\Epic Games\UE_5.0\Engine\Source\Runtime\Core\Public\GenericPlatform/GenericPlatformMisc.h(786): error C2535: 'void FGenericPlatformMisc::CustomNamedStat(const TCHAR *,float,const TCHAR *,const TCHAR *)': member function already defined or declared
C:\Program Files\Epic Games\UE_5.0\Engine\Source\Runtime\Core\Public\GenericPlatform/GenericPlatformMisc.h(785): note: see declaration of 'FGenericPlatformMisc::CustomNamedStat'
C:\Program Files\Epic Games\UE_5.0\Engine\Source\Runtime\Core\Public\Windows/WindowsPlatformMisc.h(59): error C2535: 'void FWindowsPlatformMisc::BeginNamedEvent(const FColor &,const TCHAR *)': member function already defined or declared
C:\Program Files\Epic Games\UE_5.0\Engine\Source\Runtime\Core\Public\Windows/WindowsPlatformMisc.h(58): note: see declaration of 'FWindowsPlatformMisc::BeginNamedEvent'
C:\Program Files\Epic Games\UE_5.0\Engine\Source\Runtime\Core\Public\Windows/WindowsPlatformMisc.h(62): error C2535: 'void FWindowsPlatformMisc::CustomNamedStat(const TCHAR *,float,const TCHAR *,const TCHAR *)': member function already defined or declared
C:\Program Files\Epic Games\UE_5.0\Engine\Source\Runtime\Core\Public\Windows/WindowsPlatformMisc.h(61): note: see declaration of 'FWindowsPlatformMisc::CustomNamedStat'
C:\Program Files\Epic Games\UE_5.0\Engine\Source\Runtime\Core\Public\ProfilingDebugging/CpuProfilerTrace.h(55): error C2572: 'FCpuProfilerTrace::OutputEventType': redefinition of default argument: parameter 1
C:\Program Files\Epic Games\UE_5.0\Engine\Source\Runtime\Core\Public\ProfilingDebugging/CpuProfilerTrace.h(47): note: see declaration of 'FCpuProfilerTrace::OutputEventType'
C:\Program Files\Epic Games\UE_5.0\Engine\Source\Runtime\Core\Public\ProfilingDebugging/CpuProfilerTrace.h(55): error C2572: 'FCpuProfilerTrace::OutputEventType': redefinition of default argument: parameter 2
C:\Program Files\Epic Games\UE_5.0\Engine\Source\Runtime\Core\Public\ProfilingDebugging/CpuProfilerTrace.h(47): note: see declaration of 'FCpuProfilerTrace::OutputEventType'
C:\Program Files\Epic Games\UE_5.0\Engine\Source\Runtime\Core\Public\ProfilingDebugging/CpuProfilerTrace.h(55): error C2535: 'uint32 FCpuProfilerTrace::OutputEventType(const ANSICHAR *,const ANSICHAR *,uint32)': member function already defined or declared
C:\Program Files\Epic Games\UE_5.0\Engine\Source\Runtime\Core\Public\ProfilingDebugging/CpuProfilerTrace.h(47): note: see declaration of 'FCpuProfilerTrace::OutputEventType'
C:\Program Files\Epic Games\UE_5.0\Engine\Source\Runtime\Core\Public\ProfilingDebugging/CpuProfilerTrace.h(76): error C2572: 'FCpuProfilerTrace::OutputBeginDynamicEvent': redefinition of default argument: parameter 1
C:\Program Files\Epic Games\UE_5.0\Engine\Source\Runtime\Core\Public\ProfilingDebugging/CpuProfilerTrace.h(68): note: see declaration of 'FCpuProfilerTrace::OutputBeginDynamicEvent'
C:\Program Files\Epic Games\UE_5.0\Engine\Source\Runtime\Core\Public\ProfilingDebugging/CpuProfilerTrace.h(76): error C2572: 'FCpuProfilerTrace::OutputBeginDynamicEvent': redefinition of default argument: parameter 2
C:\Program Files\Epic Games\UE_5.0\Engine\Source\Runtime\Core\Public\ProfilingDebugging/CpuProfilerTrace.h(68): note: see declaration of 'FCpuProfilerTrace::OutputBeginDynamicEvent'
C:\Program Files\Epic Games\UE_5.0\Engine\Source\Runtime\Core\Public\ProfilingDebugging/CpuProfilerTrace.h(76): error C2535: 'void FCpuProfilerTrace::OutputBeginDynamicEvent(const ANSICHAR *,const ANSICHAR *,uint32)': member function already defined or declared
C:\Program Files\Epic Games\UE_5.0\Engine\Source\Runtime\Core\Public\ProfilingDebugging/CpuProfilerTrace.h(68): note: see declaration of 'FCpuProfilerTrace::OutputBeginDynamicEvent'
C:\Program Files\Epic Games\UE_5.0\Engine\Source\Runtime\Core\Public\ProfilingDebugging/CpuProfilerTrace.h(124): error C2572: 'FCpuProfilerTrace::FDynamicEventScope::FDynamicEventScope': redefinition of default argument: parameter 1
C:\Program Files\Epic Games\UE_5.0\Engine\Source\Runtime\Core\Public\ProfilingDebugging/CpuProfilerTrace.h(115): note: see declaration of 'FCpuProfilerTrace::FDynamicEventScope::FDynamicEventScope'
C:\Program Files\Epic Games\UE_5.0\Engine\Source\Runtime\Core\Public\ProfilingDebugging/CpuProfilerTrace.h(124): error C2572: 'FCpuProfilerTrace::FDynamicEventScope::FDynamicEventScope': redefinition of default argument: parameter 2
C:\Program Files\Epic Games\UE_5.0\Engine\Source\Runtime\Core\Public\ProfilingDebugging/CpuProfilerTrace.h(115): note: see declaration of 'FCpuProfilerTrace::FDynamicEventScope::FDynamicEventScope'
C:\Program Files\Epic Games\UE_5.0\Engine\Source\Runtime\Core\Public\ProfilingDebugging/CpuProfilerTrace.h(124): error C2535: 'FCpuProfilerTrace::FDynamicEventScope::FDynamicEventScope(const ANSICHAR *,const UE::Trace::FChannel &,bool,const ANSICHAR *,uint32)': member function already defined or declared
C:\Program Files\Epic Games\UE_5.0\Engine\Source\Runtime\Core\Public\ProfilingDebugging/CpuProfilerTrace.h(115): note: see declaration of 'FCpuProfilerTrace::FDynamicEventScope::FDynamicEventScope'
C:\Program Files\Epic Games\UE_5.0\Engine\Source\Runtime\Core\Public\HAL/PlatformMisc.h(48): error C2535: 'FScopedNamedEvent::FScopedNamedEvent(const FColor &,const TCHAR *)': member function already defined or declared
C:\Program Files\Epic Games\UE_5.0\Engine\Source\Runtime\Core\Public\HAL/PlatformMisc.h(43): note: see declaration of 'FScopedNamedEvent::FScopedNamedEvent'
C:\Program Files\Epic Games\UE_5.0\Engine\Source\Runtime\Core\Public\HAL/PlatformMisc.h(94): error C2535: 'FScopedNamedEventStatic::FScopedNamedEventStatic(const FColor &,const TCHAR *)': member function already defined or declared
C:\Program Files\Epic Games\UE_5.0\Engine\Source\Runtime\Core\Public\HAL/PlatformMisc.h(85): note: see declaration of 'FScopedNamedEventStatic::FScopedNamedEventStatic'
C:\Program Files\Epic Games\UE_5.0\Engine\Source\Runtime\Core\Public\Containers/StringConv.h(989): error C2338: TCHAR and UTF16CHAR are expected to be the same size for inline conversion! PLATFORM_TCHAR_IS_4_BYTES is not configured correctly for this platform.
C:\Program Files\Epic Games\UE_5.0\Engine\Source\Runtime\Core\Public\Containers/StringConv.h(1009): error C2338: TCHAR and wchar_t are expected to be the same size for inline conversion! PLATFORM_WCHAR_IS_4_BYTES is not configured correctly for this platform.
C:\Program Files\Epic Games\UE_5.0\Engine\Source\Runtime\Core\Public\Misc/StringBuilder.h(413): error C2672: 'TStringBuilderBase<WIDECHAR>::Appendf': no matching overloaded function found
C:\Program Files\Epic Games\UE_5.0\Engine\Source\Runtime\Core\Public\Misc/StringBuilder.h(413): error C2783: 'TStringBuilderBase<WIDECHAR> &TStringBuilderBase<WIDECHAR>::Appendf(const FmtType &,Types...)': could not deduce template argument for '__formal'
C:\Program Files\Epic Games\UE_5.0\Engine\Source\Runtime\Core\Public\Misc/StringBuilder.h(299): note: see declaration of 'TStringBuilderBase<WIDECHAR>::Appendf'
C:\Program Files\Epic Games\UE_5.0\Engine\Source\Runtime\Core\Public\Misc/StringBuilder.h(414): error C2672: 'TStringBuilderBase<WIDECHAR>::Appendf': no matching overloaded function found
C:\Program Files\Epic Games\UE_5.0\Engine\Source\Runtime\Core\Public\Misc/StringBuilder.h(414): error C2783: 'TStringBuilderBase<WIDECHAR> &TStringBuilderBase<WIDECHAR>::Appendf(const FmtType &,Types...)': could not deduce template argument for '__formal'
C:\Program Files\Epic Games\UE_5.0\Engine\Source\Runtime\Core\Public\Misc/StringBuilder.h(299): note: see declaration of 'TStringBuilderBase<WIDECHAR>::Appendf'
C:\Program Files\Epic Games\UE_5.0\Engine\Source\Runtime\Core\Public\Misc/StringBuilder.h(420): error C2672: 'TStringBuilderBase<WIDECHAR>::Appendf': no matching overloaded function found
C:\Program Files\Epic Games\UE_5.0\Engine\Source\Runtime\Core\Public\Misc/StringBuilder.h(420): error C2783: 'TStringBuilderBase<WIDECHAR> &TStringBuilderBase<WIDECHAR>::Appendf(const FmtType &,Types...)': could not deduce template argument for '__formal'
C:\Program Files\Epic Games\UE_5.0\Engine\Source\Runtime\Core\Public\Misc/StringBuilder.h(299): note: see declaration of 'TStringBuilderBase<WIDECHAR>::Appendf'
C:\Program Files\Epic Games\UE_5.0\Engine\Source\Runtime\Core\Public\Misc/StringBuilder.h(421): error C2672: 'TStringBuilderBase<WIDECHAR>::Appendf': no matching overloaded function found
C:\Program Files\Epic Games\UE_5.0\Engine\Source\Runtime\Core\Public\Misc/StringBuilder.h(421): error C2783: 'TStringBuilderBase<WIDECHAR> &TStringBuilderBase<WIDECHAR>::Appendf(const FmtType &,Types...)': could not deduce template argument for '__formal'
C:\Program Files\Epic Games\UE_5.0\Engine\Source\Runtime\Core\Public\Misc/StringBuilder.h(299): note: see declaration of 'TStringBuilderBase<WIDECHAR>::Appendf'
C:\Program Files\Epic Games\UE_5.0\Engine\Source\Runtime\Core\Public\Misc/ByteSwap.h(116): error C2338: Assuming TCHAR is 2 bytes wide.
C:\Program Files\Epic Games\UE_5.0\Engine\Source\Runtime\Core\Public\Containers/StringConv.h(818): error C2338: FromType must be the same size as ToType!
C:\Program Files\Epic Games\UE_5.0\Engine\Source\Runtime\Core\Public\Internationalization/TextKey.h(17): note: see reference to class template instantiation 'TStringPointer<TCHAR,UTF16CHAR>' being compiled
C:\Program Files\Epic Games\UE_5.0\Engine\Source\Runtime\Core\Public\GenericPlatform/GenericPlatformProcess.h(739): error C2062: type 'void' unexpected
C:\Program Files\Epic Games\UE_5.0\Engine\Source\Runtime\Core\Public\GenericPlatform/GenericPlatformProcess.h(740): error C2334: unexpected token(s) preceding '{'; skipping apparent function body
C:\Program Files\Epic Games\UE_5.0\Engine\Source\Runtime\Core\Public\Stats/Stats2.h(1588): error C2664: 'void FWindowsPlatformMisc::BeginNamedEvent(const FColor &,const TCHAR *)': cannot convert argument 2 from 'const WIDECHAR *' to 'const TCHAR *'
C:\Program Files\Epic Games\UE_5.0\Engine\Source\Runtime\Core\Public\Stats/Stats2.h(1588): note: Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or parenthesized function-style cast
C:\Program Files\Epic Games\UE_5.0\Engine\Source\Runtime\Core\Public\Windows/WindowsPlatformMisc.h(58): note: see declaration of 'FWindowsPlatformMisc::BeginNamedEvent'
C:\Program Files\Epic Games\UE_5.0\Engine\Source\Runtime\Core\Public\Misc/SecureHash.h(271): error C2084: function 'FStringBuilderBase &operator <<(FStringBuilderBase &,const FSHAHash &)' already has a body