-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Labels
enhancementSomething can be improvedSomething can be improvedfixedSomething works now, yay!Something works now, yay!
Description
Currently, our STL errors look like:
#error STL1003: Unexpected compiler, expected C++ compiler.This results in the following output from MSVC:
C:\Users\nimazzuc\projects\stl\out\x64\out/inc\yvals_core.h(687): fatal error C1189: #error STL1003: Unexpected compiler, expected C++ compiler.
This is as opposed to our STL warnings, which result in much prettier output:
C:\Users\nimazzuc\projects\stl\out\x64\out/inc\yvals.h(238): warning STL4000: _STATIC_CPPLIB is deprecated and will be REMOVED.
Do we wish to use pragma message instead, so that we get prettier output?
Something like:
// yvals_core.h
// preprocessor fun
#define _STL_PRAGMA(PRAGMA) _Pragma(#PRAGMA)
#define _STL_PRAGMA_MESSAGE(MESSAGE) _STL_PRAGMA(message(MESSAGE))
// note: clang-format does weird things to this
// clang-format off
#define _ERROR_MESSAGE(NUMBER, MESSAGE) \
_STL_PRAGMA_MESSAGE(__FILE__ "(" _CRT_STRINGIZE(__LINE__) "): error STL" #NUMBER ": " MESSAGE) \
static_assert(false, "Error in C++ Standard Library usage.")
// clang-format oncalled like:
#ifndef __cplusplus
_ERROR_MESSAGE(1003, "Unexpected compiler, expected C++ compiler.");
#endifresulting in the following output:
PS C:\..\nimazzuc\projects\stl-tests> cl /c test.cxx
Microsoft (R) C/C++ Optimizing Compiler Version 19.33.31517 for x64
Copyright (C) Microsoft Corporation. All rights reserved.
test.cxx
test.cxx(12): error STL1004: Unexpected compiler, expected C++ compiler.
test.cxx(12): error C2338: static_assert failed: 'Error in C++ Standard Library usage.'
which I at least believe is far more readable (and is probably better for VS diagnostics as well)
(if we do make this change, we should do the same pragma preprocessor nonsense for _WARNING_MESSAGE
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementSomething can be improvedSomething can be improvedfixedSomething works now, yay!Something works now, yay!