API DATABASE_CONTROL EXAMPLE ERROR
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2018-12-06
03:21 AM
- last edited on
2022-10-04
04:51 PM
by
Daniel Kassai
before
DBASSERT (book->save (UNISTR_TO_LIBXLSTR(filepath)));
book->release ();
after
bool aaaa= book->save (UNISTR_TO_LIBXLSTR(filepath))
book->release();
But I keep getting the following errors in the GSException.hpp file. Can I know the problem?
Severity Code Description Project File Line Suppression Statecode for Database_Control.cpp file
Warning C4189 'aaaa': local variable is initialized but not referenced Database_Control C:\Program Files\Graphisoft\API Development Kit 22.3004\Examples\Database_Control\Src\Database_Control.cpp 1458
Severity Code Description Project File Line Suppression State
Error (active) E0028 expression must have a constant value Database_Control C:\Program Files\Graphisoft\API Development Kit 22.3004\Support\Modules\GSRoot\GSException.hpp 62
Severity Code Description Project File Line Suppression State
Error (active) E0028 expression must have a constant value Database_Control C:\Program Files\Graphisoft\API Development Kit 22.3004\Support\Modules\GSRoot\GSException.hpp 62
Severity Code Description Project File Line Suppression State
Error (active) E0145 member "GS::GSException::AlignOfUniString" may not be initialized Database_Control C:\Program Files\Graphisoft\API Development Kit 22.3004\Support\Modules\GSRoot\GSException.hpp 56
Severity Code Description Project File Line Suppression State
Error (active) E0145 member "GS::GSException::SizeOfUniString" may not be initialized Database_Control C:\Program Files\Graphisoft\API Development Kit 22.3004\Support\Modules\GSRoot\GSException.hpp 57
Severity Code Description Project File Line Suppression State
Error C2220 warning treated as error - no 'object' file generated Database_Control C:\Program Files\Graphisoft\API Development Kit 22.3004\Examples\Database_Control\Src\Database_Control.cpp 1458
static void Do_ExportWallsToExcel (void) { DBPrintf ("Exporting walls to Excel document...\n"); libxl::Book* book = xlCreateXMLBook (); libxl::Sheet* sheet = book->addSheet (UNISTR_TO_LIBXLSTR (GS::UniString("Walls exported from Archicad"))); libxl::Font* guidFormatFont = book->addFont (); guidFormatFont->setSize (6); guidFormatFont->setColor (libxl::COLOR_GRAY50); libxl::Format* guidFormat = book->addFormat (); guidFormat->setFont (guidFormatFont); GS::Array<GS::UniString> titles; titles.Push ("GUID"); titles.Push ("Height"); titles.Push ("BeginCoordX"); titles.Push ("BeginCoordY"); titles.Push ("EndCoordX"); titles.Push ("EndCoordY"); for (UIndex i = 0; i < titles.GetSize (); ++i) { sheet->writeStr (0, i, UNISTR_TO_LIBXLSTR (titles)); } GS::Array<API_Guid> apiguids; ACAPI_Element_GetElemList (API_WallID, &apiguids); for (UIndex i = 0; i < apiguids.GetSize (); ++i) { GS::Guid gsguid = APIGuid2GSGuid (apiguids); API_Element element = {}; element.header.guid = apiguids; GSErrCode err = ACAPI_Element_Get (&element); if (err != NoError) { DBPrintf ("ACAPI_Element_Get returned error (%d) for GUID '%s'\n", err, gsguid.ToUniString ().ToCStr ().Get ()); continue; } API_WallType& wall = element.wall; //DBPrintf ("GUID '%s'\n", gsguid.ToUniString ().ToCStr ().Get ()); sheet->writeStr (i + 1, 0, UNISTR_TO_LIBXLSTR (gsguid.ToUniString ()), guidFormat); sheet->writeNum (i + 1, 1, wall.height); sheet->writeNum (i + 1, 2, wall.begC.x); sheet->writeNum (i + 1, 3, wall.begC.y); sheet->writeNum (i + 1, 4, wall.endC.x); sheet->writeNum (i + 1, 5, wall.endC.y); } IO::Location location; IO::fileSystem.GetSpecialLocation (IO::FileSystem::UserDocuments, &location); location.AppendToLocal (IO::Name ("export.xlsx")); GS::UniString filepath; location.ToPath (&filepath); DBASSERT (book->save (UNISTR_TO_LIBXLSTR(filepath))); book->release (); DBPrintf ("Export operation finished\n"); }code for GSException.hpp file
// ***************************************************************************** // // Class GSException // // Module: GSRoot // Namespace: GS // Contact person: MB, FGY, MM // // SG compatible // // ***************************************************************************** #ifndef GSEXCEPTION_HPP #define GSEXCEPTION_HPP #pragma once #include <stdio.h> #include <exception> #include <new> #include "GSRootExport.hpp" #include "Definitions.hpp" #include "GSDebug.hpp" namespace GS { class ClassInfo; } namespace GS { class OChannel; } namespace GS { class UniString; } #include "StackInfo.hpp" // Undefine Windows Macros, we want to use "GetMessage" #if defined (WINDOWS) #if defined (GetMessage) #undef GetMessage #endif #endif // ============================== Class GSException ============================== #define GS_EXCEPTIONS_DLL_EXPORTED namespace GS { #define GS_EXCEPTIONS_INLINE #define GS_EXCEPTIONS_GSROOT_DLL_EXPORT GSROOT_DLL_EXPORT class GSROOT_DLL_EXPORT GSException { // DECLARE_DYNAMIC_CLASS public: typedef StackInfoCustomDepth<128> StackInfo; private: static constexpr USize AlignOfUniString = alignof (void*); static constexpr USize SizeOfUniString = 2 * sizeof (void*); Int32 id; // this is the equivalent error id (it is the same for the given type of exception) GS::UniString& message; // additional message for the exception from the thrower (if it isn't nullptr) alignas (AlignOfUniString) char messageStorage[SizeOfUniString]; const char* fileName; // name of file where the exception was thrown from (if it isn't nullptr) UInt32 lineNumber; // line number where the exception was thrown from (if it isn't 0) GSException* cause; // exception chaining GSException::StackInfo stackInfo; void SetCause (const GSException* cause); void SetCause (const GSException& cause); public: // Constructors explicit GSException (const char* message = nullptr, const char* fileName = nullptr, UInt32 lineNumber = 0, const GSException* cause = nullptr, Int32 id = 0 // should be wired in all of the derived classes ); explicit GSException (const char* message, const char* fileName, UInt32 lineNumber, const GSException& cause, Int32 id // should be wired in all of the derived classes ); explicit GSException (const GS::UniString& message, const char* fileName = nullptr, UInt32 lineNumber = 0, const GSException* cause = nullptr, Int32 id = 0 // should be wired in all of the derived classes ); explicit GSException ( const GS::UniString& message, const char* fileName, UInt32 lineNumber, const GSException& cause, Int32 id // should be wired in all of the derived classes ); GSException (const GSException& source); virtual ~GSException () throw (); // User interface void SetMessage (const GS::UniString& message); void SetMessage (const char* message); virtual const char* GetName (void) const; virtual Int32 GetID (void) const; virtual const GS::UniString& GetMessage (void) const; virtual const char* GetFileName (void) const; virtual UInt32 GetLineNumber (void) const; virtual GSException* Clone (void) const; virtual void Print (OChannel& oc) const; virtual void Dump (OChannel& oc) const; virtual const GSException* GetCause () const; virtual GSException* GetCause (); virtual const StackInfo& GetStack () const; GSException& operator= (const GSException& source); }; extern const GSROOT_DLL_EXPORT GSException NoCauseException; // Special value used when there's no cause of the exception typedef GSException Exception; // GS::Exception // ______________________________ Class GSException ______________________________ // ======================= GSException hierarchy framework ======================= class GS_EXCEPTIONS_GSROOT_DLL_EXPORT RootException : virtual public GSException { public: explicit RootException (const char* msg, const char* fName, UInt32 lNumber, const GSException& cause_) : GSException (msg, fName, lNumber, cause_, (Int32)Error) {} explicit RootException (const char* msg = nullptr, const char* fName = nullptr, UInt32 lNumber = 0) : GSException (msg, fName, lNumber, nullptr, (Int32)Error) {} explicit RootException (const GS::UniString& msg, const char* fName, UInt32 lNumber, const GSException& cause_) : GSException (msg, fName, lNumber, cause_, (Int32)Error) {} explicit RootException (const GS::UniString& msg, const char* fName = nullptr, UInt32 lNumber = 0) : GSException (msg, fName, lNumber, nullptr, (Int32)Error) {} virtual const char* GetName () const override; virtual GSException* Clone (void) const override; }; class GS_EXCEPTIONS_GSROOT_DLL_EXPORT GeneralException : virtual public GSException { public: explicit GeneralException (const char* msg, const char* fName, UInt32 lNumber, const GSException& cause_) : GSException (msg, fName, lNumber, cause_, (Int32)Error) {} explicit GeneralException (const char* msg = nullptr, const char* fName = nullptr, UInt32 lNumber = 0) : GSException (msg, fName, lNumber, nullptr, (Int32)Error) {} explicit GeneralException (const GS::UniString& msg, const char* fName, UInt32 lNumber, const GSException& cause_) : GSException (msg, fName, lNumber, cause_, (Int32)Error) {} explicit GeneralException (const GS::UniString& msg, const char* fName = nullptr, UInt32 lNumber = 0) : GSException (msg, fName, lNumber, nullptr, (Int32)Error) {} virtual const char* GetName () const override; virtual GSException* Clone (void) const override; }; #define DECLARE_EXCEPTION_CLASS_WITH_CLASS_SPEC(classSpec, className, baseClassName, errId) \ class classSpec: virtual public baseClassName { \ public: \ explicit className (const char* msg, const char* fName, UInt32 lNumber, const GS::GSException& cause); \ explicit className (const char* msg = nullptr, const char* fName = nullptr, UInt32 lNumber = 0); \ explicit className (const GS::UniString& msg, const char* fName, UInt32 lNumber, const GS::GSException& cause); \ explicit className (const GS::UniString& msg, const char* fName = nullptr, UInt32 lNumber = 0); \ virtual const char* GetName () const override; \ virtual GS::GSException* Clone (void) const override; \ }; #define DECLARE_EXCEPTION_CLASS(className, baseClassName, errId, exportdef) \ DECLARE_EXCEPTION_CLASS_WITH_CLASS_SPEC(exportdef className, className, baseClassName, errId) #define DECLARE_EXCEPTION_CLASS_NO_EXPORTDEF(className, baseClassName, errId) \ DECLARE_EXCEPTION_CLASS_WITH_CLASS_SPEC(className, className, baseClassName, errId) #define IMPLEMENT_EXCEPTION_CLASS_WITH_NAMESPACE(classNameWithNamespace, className, baseClassName, errId) \ classNameWithNamespace::className (const char* msg, const char* fName, UInt32 lNumber, const GS::GSException& cause): \ GS::GSException (msg, fName, lNumber, cause, errId), baseClassName () {} \ classNameWithNamespace::className (const char* msg, const char* fName, UInt32 lNumber): \ GS::GSException (msg, fName, lNumber, nullptr, errId), baseClassName () {} \ classNameWithNamespace::className (const GS::UniString& msg, const char* fName, UInt32 lNumber, const GS::GSException& cause): \ GS::GSException (msg, fName, lNumber, cause, errId), baseClassName () {} \ classNameWithNamespace::className (const GS::UniString& msg, const char* fName, UInt32 lNumber): \ GS::GSException (msg, fName, lNumber, nullptr, errId), baseClassName () {} \ const char* classNameWithNamespace::GetName () const { return #className; } \ GS::GSException* classNameWithNamespace::Clone (void) const { return new className (*this); } #define IMPLEMENT_EXCEPTION_CLASS(className, baseClassName, errId) \ IMPLEMENT_EXCEPTION_CLASS_WITH_NAMESPACE (className, className, baseClassName, errId) #define DECLARE_EXCEPTION_CLASS2(className, baseClassName1, baseClassName2, errId, exportdef) \ class exportdef className: virtual public baseClassName1, virtual public baseClassName2 { \ public: \ explicit className (const char* msg, const char* fName, UInt32 lNumber, const GS::GSException& cause); \ explicit className (const char* msg = nullptr, const char* fName = nullptr, UInt32 lNumber = 0); \ explicit className (const GS::UniString& msg, const char* fName, UInt32 lNumber, const GS::GSException& cause); \ explicit className (const GS::UniString& msg, const char* fName = nullptr, UInt32 lNumber = 0); \ virtual const char* GetName () const override; \ virtual GS::GSException* Clone (void) const override; \ }; #define IMPLEMENT_EXCEPTION_CLASS2(className, baseClassName1, baseClassName2, errId) \ className::className (const char* msg, const char* fName, UInt32 lNumber, const GS::GSException& cause): \ GS::GSException (msg, fName, lNumber, cause, errId), baseClassName1 (), baseClassName2 () {} \ className::className (const char* msg, const char* fName, UInt32 lNumber): \ GS::GSException (msg, fName, lNumber, nullptr, errId), baseClassName1 (), baseClassName2 () {} \ className::className (const GS::UniString& msg, const char* fName, UInt32 lNumber, const GS::GSException& cause): \ GS::GSException (msg, fName, lNumber, cause, errId), baseClassName1 (), baseClassName2 () {} \ className::className (const GS::UniString& msg, const char* fName, UInt32 lNumber): \ GS::GSException (msg, fName, lNumber, nullptr, errId), baseClassName1 (), baseClassName2 () {} \ const char* className::GetName () const { return #className; } \ GS::GSException* className::Clone (void) const { return new className (*this); } DECLARE_EXCEPTION_CLASS (LogicErrorException, GeneralException, Error, GSROOT_DLL_EXPORT) DECLARE_EXCEPTION_CLASS (PreconditionException, LogicErrorException, ErrParam, GSROOT_DLL_EXPORT) DECLARE_EXCEPTION_CLASS (IllegalArgumentException, PreconditionException, ErrParam, GSROOT_DLL_EXPORT) DECLARE_EXCEPTION_CLASS (IllegalReferenceException, IllegalArgumentException, ErrParam, GSROOT_DLL_EXPORT) DECLARE_EXCEPTION_CLASS (NullPointerException, IllegalArgumentException, ErrParam, GSROOT_DLL_EXPORT) DECLARE_EXCEPTION_CLASS (NullReferenceException, IllegalArgumentException, ErrParam, GSROOT_DLL_EXPORT) DECLARE_EXCEPTION_CLASS (NullHandleException, IllegalArgumentException, ErrParam, GSROOT_DLL_EXPORT) DECLARE_EXCEPTION_CLASS (EmptyHandleException, IllegalArgumentException, ErrParam, GSROOT_DLL_EXPORT) DECLARE_EXCEPTION_CLASS (IllegalTypeException, IllegalArgumentException, ErrParam, GSROOT_DLL_EXPORT) DECLARE_EXCEPTION_CLASS (RunTimeErrorException, GeneralException, Error, GSROOT_DLL_EXPORT) DECLARE_EXCEPTION_CLASS (AccessViolationException, RunTimeErrorException, Error, GSROOT_DLL_EXPORT) DECLARE_EXCEPTION_CLASS (LimitViolationException, RunTimeErrorException, Error, GSROOT_DLL_EXPORT) DECLARE_EXCEPTION_CLASS (ConversionErrorException, RunTimeErrorException, Error, GSROOT_DLL_EXPORT) DECLARE_EXCEPTION_CLASS (InternalErrorException, RunTimeErrorException, Error, GSROOT_DLL_EXPORT) DECLARE_EXCEPTION_CLASS (IllegalStateException, RunTimeErrorException, Error, GSROOT_DLL_EXPORT) DECLARE_EXCEPTION_CLASS (UnsupportedOperationException, RunTimeErrorException, Error, GSROOT_DLL_EXPORT) DECLARE_EXCEPTION_CLASS2 (OutOfMemoryException, RunTimeErrorException, std::bad_alloc, ErrMemoryFull, GSROOT_DLL_EXPORT) // General implementation of the precondition #define PRECOND_IMP(preCondition, exception) \ if (!(preCondition)) { \ DBBREAK (); \ throw exception (nullptr, __FILE__, __LINE__); \ } // Preconditions that will be compiled only into the debug and test versions #define PRECOND(condition) DBASSERT(condition) #define ARG_CHECK(condition) DBASSERT(condition) #define REF_CHECK(condition) DBASSERT(condition) #define NULL_PTR_CHECK(ptr) DBASSERT(ptr != nullptr) #define NULL_REF_CHECK(ref) DBASSERT(&ref != nullptr) #define TYPE_CHECK(condition) DBASSERT(condition) // Preconditions that will always be compiled (debug, test and release) #define PRECOND_R(condition) PRECOND_IMP(condition, GS::PreconditionException) #define ARG_CHECK_R(condition) PRECOND_IMP(condition, GS::IllegalArgumentException) #define REF_CHECK_R(condition) PRECOND_IMP(condition, GS::IllegalReferenceException) #define NULL_PTR_CHECK_R(ptr) PRECOND_IMP(ptr != nullptr, GS::NullPointerException) #define NULL_REF_CHECK_R(ref) PRECOND_IMP(&ref != nullptr, GS::NullReferenceException) #define TYPE_CHECK_R(condition) PRECOND_IMP(condition, GS::IllegalTypeException) // _______________________ GSException hierarchy framework _______________________ } #endif
Solved! Go to Solution.
- Labels:
-
Add-On (C++)
Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2018-12-15 10:01 AM
ARCHICAD 21 and 22 both use the Visual Studio 2015 compiler for building add-on projects.
You can use Visual Studio 2017 of course, but please make sure to set Visual Studio 2015 (v140) platform toolset (see attached image below).
For further informations please read our blog post about working in Visual Studio 2017:
Regards,
Tibor

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2018-12-06 10:40 AM
Could you please tell us, which version of the API Development Kit and Visual Studio are you using?
Thanks,
Dénes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2018-12-07 03:55 PM
Thanks for the reply.
API Development Kit 22.3004
Visual Studio 2017

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2018-12-15 10:01 AM
ARCHICAD 21 and 22 both use the Visual Studio 2015 compiler for building add-on projects.
You can use Visual Studio 2017 of course, but please make sure to set Visual Studio 2015 (v140) platform toolset (see attached image below).
For further informations please read our blog post about working in Visual Studio 2017:
Regards,
Tibor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2018-12-17 02:35 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2018-12-20 08:18 AM