cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 
Archicad C++ API
About Archicad add-on development using the C++ API.
SOLVED!

Compile error on Mac

dushyant
Enthusiast

Hi, 

I'm getting a compile error on Mac:

 

 /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk/usr/include/c++/v1/locale:2827:22: no member named 'GS_realloc' in namespace 'std'; did you mean simply 'GS_realloc'?

    _Tp* __t = (_Tp*)std::realloc(__owns ? __b.get() : 0, __new_cap);

 

The same code compiles fine with MSVC on windows.

Anyone faced this error?

 

Thanks.

26 REPLIES 26

Try the shortcut trick to "fool" your Xcode into the right path, it might work, the internal files if not the same are very similar and will still work. 

I'd believe it has something to do with how the template made with cmake forces the compiler to restrict the compilation at this point.

Archicad User Since 2013
GDL Developer
Experimenting with API
from Brazil
Solution

Something that worked for me is to create a .pch (precompiled header file) with this content:

 

#include "GSRoot.hpp"

namespace std {
void* GS_realloc (void *userData, size_t newSize);
}

(from Ben Cohen) also add the file path to the pch file in the PREFIX_HEADER parameter. (in Building Settings).

Hi Akos

 

Could you please provide some more information on adding the pch to the project..

I have created and added a .pch to my project and then enabled precompiled headers in Xcode - but still I am still getting this error..

I am getting a bit desperate - there for the question!!

 

Thanks In Advance..

 

UPDATE: Found the issue - I needed to also add the file path to the pch file in the PREFIX_HEADER parameter. (in Building Settings). once this was done.. all good..

 

Ben Cohen
Mac and PC
Archicad (Latest Version) aus
www.4DLibrary.com.au

Hi Ben,

 

Happy to hear that 🙂 Sorry I forgot to mention that in the original post.

 

Best, Akos


@Viktor Kovacs wrote:

This issue occurs because there was a change in the latest Xcode SDK that is not compatible with the Development Kit. Although earlier it was possible to always use the latest Xcode, unfortunately it's not the case anymore.


Hi Viktor - what is the nature of the incompatibility? Is it purely a compilation problem or is there an underlying technical issue with something like memory management?

Ralph Wessel BArch
Central Innovation

Hey Ralph,

 

API headers most of the time include a header called GSMalloc.hpp. This header introduces some macros:

#define	calloc(n, s)      GS_calloc(n, s)
#define	malloc(s)         GS_malloc(s)
#define	free(p)           GS_free(p)
#define	realloc(p, s)     GS_realloc(p, s)

Now with the latest macOS SDK they have switched from using simply malloc to std::malloc. So when GS headers come before macOS SDK headers, the compiler will get std::GS_malloc after preprocessing, and this is not able to compile.

Yeah, I've been able to work around that and currently using Xcode 16.2 for everything. My main concern is to ensure there aren't any deeper issues…

Ralph Wessel BArch
Central Innovation