Skip to content

Commit

Permalink
Correctly distinguish between windows and MSVC (#5851)
Browse files Browse the repository at this point in the history
Partially sorts #5843
  • Loading branch information
expipiplus1 authored Dec 12, 2024
1 parent 7279c04 commit 48ac6f2
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 11 deletions.
7 changes: 3 additions & 4 deletions include/slang.h
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,9 @@ convention for interface methods.
#if defined(_MSC_VER)
#define SLANG_DLL_EXPORT __declspec(dllexport)
#else
#if 0 && __GNUC__ >= 4
// Didn't work on latest gcc on linux.. so disable for now
// https://gcc.gnu.org/wiki/Visibility
#define SLANG_DLL_EXPORT __attribute__((dllexport))
#if SLANG_WINDOWS_FAMILY
#define SLANG_DLL_EXPORT \
__attribute__((dllexport)) __attribute__((__visibility__("default")))
#else
#define SLANG_DLL_EXPORT __attribute__((__visibility__("default")))
#endif
Expand Down
6 changes: 4 additions & 2 deletions source/compiler-core/windows/slang-win-visual-studio-util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,15 @@ static SlangResult _readRegistryKey(const char* path, const char* keyName, Strin

// Make easier to set up the array

static DownstreamCompilerMatchVersion _makeVersion(int main)
[[maybe_unused]] static DownstreamCompilerMatchVersion _makeVersion(int main)
{
DownstreamCompilerMatchVersion version;
version.type = SLANG_PASS_THROUGH_VISUAL_STUDIO;
version.matchVersion.set(main);
return version;
}

static DownstreamCompilerMatchVersion _makeVersion(int main, int dot)
[[maybe_unused]] static DownstreamCompilerMatchVersion _makeVersion(int main, int dot)
{
DownstreamCompilerMatchVersion version;
version.type = SLANG_PASS_THROUGH_VISUAL_STUDIO;
Expand Down Expand Up @@ -149,6 +149,7 @@ static SlangResult _parseVersion(UnownedStringSlice versionString, SemanticVersi

/* static */ DownstreamCompilerMatchVersion WinVisualStudioUtil::getCompiledVersion()
{
#ifdef _MSC_VER
// Get the version of visual studio used to compile this source
// Not const, because otherwise we get an warning/error about constant expression...
uint32_t version = _MSC_VER;
Expand Down Expand Up @@ -247,6 +248,7 @@ static SlangResult _parseVersion(UnownedStringSlice versionString, SemanticVersi
SLANG_PASS_THROUGH_VISUAL_STUDIO,
MatchSemanticVersion::makeFuture());
}
#endif

// Unknown version
return DownstreamCompilerMatchVersion(SLANG_PASS_THROUGH_VISUAL_STUDIO, MatchSemanticVersion());
Expand Down
6 changes: 3 additions & 3 deletions source/core/slang-allocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "slang-common.h"

#include <stdlib.h>
#ifdef _MSC_VER
#if SLANG_WINDOWS_FAMILY
#include <malloc.h>
#endif

Expand All @@ -14,7 +14,7 @@ namespace Slang
{
inline void* alignedAllocate(size_t size, size_t alignment)
{
#ifdef _MSC_VER
#if SLANG_WINDOWS_FAMILY
return _aligned_malloc(size, alignment);
#elif defined(__CYGWIN__)
return aligned_alloc(alignment, size);
Expand All @@ -27,7 +27,7 @@ inline void* alignedAllocate(size_t size, size_t alignment)

inline void alignedDeallocate(void* ptr)
{
#ifdef _MSC_VER
#if SLANG_WINDOWS_FAMILY
_aligned_free(ptr);
#else
free(ptr);
Expand Down
2 changes: 1 addition & 1 deletion source/core/slang-platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ SLANG_COMPILE_TIME_ASSERT(E_OUTOFMEMORY == SLANG_E_OUT_OF_MEMORY);
/* static */ void* SharedLibrary::findSymbolAddressByName(Handle handle, char const* name)
{
SLANG_ASSERT(handle);
return GetProcAddress((HMODULE)handle, name);
return reinterpret_cast<void*>(GetProcAddress((HMODULE)handle, name));
}

/* static */ void SharedLibrary::appendPlatformFileName(
Expand Down
2 changes: 1 addition & 1 deletion source/core/slang-secure-crt.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#ifndef _MSC_VER
#ifndef _WIN32
#ifndef SLANG_CORE_SECURE_CRT_H
#define SLANG_CORE_SECURE_CRT_H
#include <assert.h>
Expand Down

0 comments on commit 48ac6f2

Please sign in to comment.