View Issue Details

IDProjectCategoryView StatusLast Update
0001690NoesisGUIC++ SDKpublic2020-05-28 14:45
ReporterstevehAssigned Tojsantos 
PrioritynormalSeverityminorReproducibilityN/A
Status resolvedResolutionfixed 
Product Version3.0.0 
Target Version3.0.1Fixed in Version 
Summary0001690: Suggestion: Remove exposed include to platform headers
DescriptionHi guys,

I'm currently moving our code base over to 3.0.0 RC7 (well technically your SVN trunk head revision) in preparation for the 3.0.0 official release. Note: I'm only using the RC to get our code working locally against the 3.0.0 version, I don't plan to submit the integration until you create a tag for the official 3.0.0 release so I have an official version to work against.

I hit another snag. We had several references to FrameworkElement::TryFindResource in our code base. It looks like this has now been removed and replaced with FrameworkElement::FindResource and it no longer looks to throw an error if an invalid resource is requested. I've replaced the instances but then I hit another compile error, similar to the PlaySound error (https://www.noesisengine.com/bugs/view.php?id=1637). It looks like WinAPI redefines FindResource -> FindResourceA / FindResourceW depending on unicode settings (https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-findresourcea)

I think the simplest fix is to remove any reference to #include <windows.h> in the header. Here are the references I could find in the headers:

NoesisSDK\Src\Packages\Core\Kernel\Inc\NsCore\SpinMutex.h(19)
NoesisSDK\Src\Packages\Core\Kernel\Inc\NsCore\Thread.h(19)
NoesisSDK\Src\Packages\Core\Kernel\Inc\NsCore\TLSValue.h(19)
NoesisSDK\Src\Packages\Core\Kernel\Include\NsCore\CpuProfiler.h(40)
NoesisSDK\Src\Packages\Core\Kernel\Src\ECC.h(167)
NoesisSDK\Src\Packages\Core\Kernel\Src\RecursiveMutex.h(19)


It would be nice if these platform layer types could be abstracted away into a platform independent type, and then all platform include headers could be removed from external code.

For the time being, I've changed my code to do something like the following:



///////////////////////////////////////////////////////////////////////////
// Backup the FindResource defintion overridden by WinAPI

#ifdef FindResource
#define FindResourceBackup FindResource
#undef FindResource
#endif

// ... Code which uses FindResource

///////////////////////////////////////////////////////////////////////////
// Restore FindResource

#ifdef FindResourceBackup
#define FindResource FindResourceBackup
#endif



This is obviously not ideal, but it gets the code compiling.

Cheers!
Steps To Reproduce- Compile NoesisGUI as a static lib
- Include Noesis Headers
- Try to call FindResource(...). It'll throw a compile error.
TagsNo tags attached.
PlatformAny

Activities

jsantos

jsantos

2020-05-20 10:38

manager   ~0006384

Yes, windows.h again.... :(

Problem is, we want SpinMutex and all headers to be inline (for performance) so what I am going to do is just copying the definitions inside windows.h and put exactly what I need instead of doing include windows.

We will try to solve this in 3.0.1 (3.0.0 is locked now)

Issue History

Date Modified Username Field Change
2020-05-19 15:17 steveh New Issue
2020-05-20 10:35 jsantos Assigned To => jsantos
2020-05-20 10:35 jsantos Status new => assigned
2020-05-20 10:35 jsantos Target Version => 3.0.0
2020-05-20 10:38 jsantos Note Added: 0006384
2020-05-20 10:39 jsantos Target Version 3.0.0 => 3.0
2020-05-26 13:30 jsantos Target Version 3.0 => 3.0.1
2020-05-28 14:45 jsantos Status assigned => resolved
2020-05-28 14:45 jsantos Resolution open => fixed