Turn on and fix MSVC compliance mode issues

We want /permissive- to enable debug performance improvements in MSVC 17.5+.
This flag is also default under C++20 so we'll have to deal with these compile issues anyway at some point in the future.

In particular, MSVC becomes pedantic about ternary types.
See https://learn.microsoft.com/en-us/cpp/build/reference/permissive-standards-conformance?view=msvc-170#ambiguous-conditional-operator-arguments

MSFT cites https://cplusplus.github.io/CWG/issues/1805.html
This commit is contained in:
Marek Roszko 2023-02-12 16:29:26 -05:00
parent 6af3dadaee
commit 4665823089
28 changed files with 56 additions and 43 deletions

View File

@ -466,6 +466,9 @@ if( MSVC )
string( APPEND CMAKE_CXX_FLAGS_RELWITHDEBINFO " /Gy" )
# Avoid fatal error because /GF + swig wrapper exceed standard obj file limits
string( APPEND CMAKE_CXX_FLAGS " /bigobj" )
# /permissive-: This puts MSVC into compliance mode, this flag is default on with C++20
# but we want to turn it on to enable debug performance improvements available under C++17 in MSVC 17.5+
string( APPEND CMAKE_CXX_FLAGS " /permissive-" )
# Exception handling
# Remove the potential default EHsc option cmake doesn't allow us to remove easily

View File

@ -276,7 +276,7 @@ bool LIB_ID::isLegalLibraryNameChar( unsigned aUniChar )
const wxString LIB_ID::GetFullLibraryName() const
{
wxString suffix = m_subLibraryName.wx_str().IsEmpty()
? wxS( "" )
? wxString( wxS( "" ) )
: wxString::Format( wxT( " - %s" ), m_subLibraryName.wx_str() );
return wxString::Format( wxT( "%s%s" ), m_libraryName.wx_str(), suffix );
}

View File

@ -581,7 +581,7 @@ bool COMPILER::lexDefault( T_TOKEN& aToken )
const wxString formatNode( TREE_NODE* node )
{
return node->value.str ? *(node->value.str) : "";
return node->value.str ? *(node->value.str) : wxString( wxEmptyString );
}

View File

@ -1430,7 +1430,7 @@ public:
{
return aRefName
+ ( ( aAlternateName.size() > 0 ) ? ( wxT( " (" ) + aAlternateName + wxT( ")" ) )
: wxT( "" ) );
: wxString( wxT( "" ) ) );
}

View File

@ -29,7 +29,7 @@ APP_PROGRESS_DIALOG::APP_PROGRESS_DIALOG( const wxString& aTitle, const wxString
int aMaximum, wxWindow* aParent,
bool aIndeterminateTaskBarStatus, int aStyle )
: wxProgressDialog( aTitle,
aMessage == wxEmptyString ? wxT( " " ) : aMessage,
aMessage == wxEmptyString ? wxString( wxT( " " ) ) : aMessage,
aMaximum, aParent, aStyle )
#if wxCHECK_VERSION( 3, 1, 0 )
,

View File

@ -225,7 +225,7 @@ void DIALOG_RESCUE_EACH::PopulateInstanceList()
data.clear();
data.push_back( eachSymbol->GetRef( m_currentSheet ) );
data.push_back( valueField ? valueField->GetText() : wxT( "" ) );
data.push_back( valueField ? valueField->GetText() : wxString( wxT( "" ) ) );
m_ListOfInstances->AppendItem( data );
count++;
}

View File

@ -93,7 +93,7 @@ bool PANEL_EESCHEMA_DISPLAY_OPTIONS::TransferDataFromWindow()
EESCHEMA_SETTINGS* cfg = mgr.GetAppSettings<EESCHEMA_SETTINGS>();
cfg->m_Appearance.default_font = m_defaultFontCtrl->GetSelection() <= 0
? KICAD_FONT_NAME // This is a keyword. Do not translate
? wxString( KICAD_FONT_NAME ) // This is a keyword. Do not translate
: m_defaultFontCtrl->GetStringSelection();
cfg->m_Appearance.show_hidden_pins = m_checkShowHiddenPins->GetValue();
cfg->m_Appearance.show_hidden_fields = m_checkShowHiddenFields->GetValue();

View File

@ -352,7 +352,7 @@ wxString SCH_CONNECTION::Name( bool aIgnoreSheet ) const
void SCH_CONNECTION::recacheName()
{
m_cached_name =
m_name.IsEmpty() ? wxT( "<NO NET>" ) : wxString( m_prefix ) << m_name << m_suffix;
m_name.IsEmpty() ? wxString( wxT( "<NO NET>" ) ) : wxString( m_prefix ) << m_name << m_suffix;
bool prepend_path = true;

View File

@ -1799,7 +1799,7 @@ SCH_SYMBOL* CADSTAR_SCH_ARCHIVE_LOADER::loadSchematicSymbol( const SYMBOL& aCads
return nullptr;
}
wxString gate = ( aCadstarSymbol.GateID.IsEmpty() ) ? wxT( "A" ) : aCadstarSymbol.GateID;
wxString gate = ( aCadstarSymbol.GateID.IsEmpty() ) ? wxString( wxT( "A" ) ) : aCadstarSymbol.GateID;
wxString partGateIndex = aCadstarSymbol.PartRef.RefID + gate;
//Handle pin swaps

View File

@ -1871,7 +1871,7 @@ EAGLE_LIBRARY* SCH_EAGLE_PLUGIN::loadLibrary( wxXmlNode* aLibraryNode,
// Get Device set information
EDEVICE_SET edeviceset = EDEVICE_SET( devicesetNode );
wxString prefix = edeviceset.prefix ? edeviceset.prefix.Get() : wxT( "" );
wxString prefix = edeviceset.prefix ? edeviceset.prefix.Get() : wxString( wxT( "" ) );
NODE_MAP deviceSetChildren = MapChildren( devicesetNode );
wxXmlNode* deviceNode = getChildrenNodes( deviceSetChildren, wxT( "devices" ) );
@ -2380,7 +2380,7 @@ LIB_TEXT* SCH_EAGLE_PLUGIN::loadSymbolText( std::unique_ptr<LIB_SYMBOL>& aSymbol
adjustedText += tmp;
}
libtext->SetText( adjustedText.IsEmpty() ? wxT( "~" ) : adjustedText );
libtext->SetText( adjustedText.IsEmpty() ? wxString( wxT( "~" ) ) : adjustedText );
loadTextAttributes( libtext.get(), etext );
return libtext.release();
@ -2596,7 +2596,7 @@ SCH_TEXT* SCH_EAGLE_PLUGIN::loadPlainText( wxXmlNode* aSchText )
adjustedText += tmp;
}
schtext->SetText( adjustedText.IsEmpty() ? wxT( "\" \"" ) : escapeName( adjustedText ) );
schtext->SetText( adjustedText.IsEmpty() ? wxString( wxT( "\" \"" ) ) : escapeName( adjustedText ) );
schtext->SetPosition( VECTOR2I( etext.x.ToSchUnits(), -etext.y.ToSchUnits() ) );
loadTextAttributes( schtext.get(), etext );
schtext->SetItalic( false );

View File

@ -755,7 +755,7 @@ int SCH_REFERENCE_LIST::CheckAnnotation( ANNOTATION_ERROR_HANDLER aHandler )
first.GetRef(),
tmp,
first.GetLibPart()->GetUnitCount() > 1 ?
LIB_SYMBOL::SubReference( first.m_unit ) : wxT( "" ) );
LIB_SYMBOL::SubReference( first.m_unit ) : wxString( wxT( "" ) ) );
aHandler( ERCE_DUPLICATE_REFERENCE, msg, &first, &m_flatList[ii+1] );
error++;

View File

@ -1232,7 +1232,7 @@ bool SCH_SHEET::addInstance( const SCH_SHEET_PATH& aSheetPath )
wxLogTrace( traceSchSheetPaths, wxT( "Adding instance `%s` to sheet `%s`." ),
aSheetPath.Path().AsString(),
( GetName().IsEmpty() ) ? wxT( "root" ) : GetName() );
( GetName().IsEmpty() ) ? wxString( wxT( "root" ) ) : GetName() );
SCH_SHEET_INSTANCE instance;

View File

@ -1138,7 +1138,7 @@ void SCH_SHEET_LIST::UpdateSheetInstanceData( const std::vector<SCH_SHEET_INSTAN
}
wxLogTrace( traceSchSheetPaths, "Setting sheet '%s' instance '%s' page number '%s'",
( sheet->GetName().IsEmpty() ) ? wxT( "root" ) : sheet->GetName(),
( sheet->GetName().IsEmpty() ) ? wxString( wxT( "root" ) ) : sheet->GetName(),
path.Path().AsString(), it->m_PageNumber );
path.SetPageNumber( it->m_PageNumber );
}

View File

@ -1265,17 +1265,19 @@ bool SCH_SYMBOL::ResolveTextVar( wxString* token, int aDepth ) const
}
else if( token->IsSameAs( wxT( "EXCLUDE_FROM_BOM" ) ) )
{
*token = this->GetIncludeInBom() ? wxT( "" ) : _( "Excluded from BOM" );
*token = this->GetIncludeInBom() ? wxString( wxT( "" ) )
: _( "Excluded from BOM" );
return true;
}
else if( token->IsSameAs( wxT( "EXCLUDE_FROM_BOARD" ) ) )
{
*token = this->GetIncludeOnBoard() ? wxT( "" ) : _( "Excluded from board" );
*token = this->GetIncludeOnBoard() ? wxString( wxT( "" ) )
: _( "Excluded from board" );
return true;
}
else if( token->IsSameAs( wxT( "DNP" ) ) )
{
*token = this->GetDNP() ? _( "DNP" ) : wxT( "" );
*token = this->GetDNP() ? _( "DNP" ) : wxString( wxT( "" ) );
return true;
}

View File

@ -194,22 +194,22 @@ public:
wxString GetLabelX() const
{
return m_axis_x ? m_axis_x->GetName() : wxS( "" );
return m_axis_x ? m_axis_x->GetName() : wxString( wxS( "" ) );
}
wxString GetLabelY1() const
{
return m_axis_y1 ? m_axis_y1->GetName() : wxS( "" );
return m_axis_y1 ? m_axis_y1->GetName() : wxString( wxS( "" ) );
}
wxString GetLabelY2() const
{
return m_axis_y2 ? m_axis_y2->GetName() : wxS( "" );
return m_axis_y2 ? m_axis_y2->GetName() : wxString( wxS( "" ) );
}
wxString GetLabelY3() const
{
return m_axis_y3 ? m_axis_y3->GetName() : wxS( "" );
return m_axis_y3 ? m_axis_y3->GetName() : wxString( wxS( "" ) );
}
wxString GetUnitsX() const;

View File

@ -54,31 +54,39 @@ wxString SPICE_SIMULATOR::TypeToName( SIM_TYPE aType, bool aShortName )
switch( aType )
{
case ST_OP:
return aShortName ? wxT( "OP" ) : _( "Operating Point" );
return aShortName ? wxString( wxT( "OP" ) )
: _( "Operating Point" );
case ST_AC:
return "AC";
case ST_DC:
return aShortName ? wxT( "DC" ) : _( "DC Sweep" );
return aShortName ? wxString( wxT( "DC" ) )
: _( "DC Sweep" );
case ST_TRANSIENT:
return aShortName ? wxT( "TRAN" ) : _( "Transient" );
return aShortName ? wxString( wxT( "TRAN" ) )
: _( "Transient" );
case ST_DISTORTION:
return aShortName ? wxT( "DISTO" ) : _( "Distortion" );
return aShortName ? wxString( wxT( "DISTO" ) )
: _( "Distortion" );
case ST_NOISE:
return aShortName ? wxT( "NOISE" ) : _( "Noise" );
return aShortName ? wxString( wxT( "NOISE" ) )
: _( "Noise" );
case ST_POLE_ZERO:
return aShortName ? wxT( "PZ" ) : _( "Pole-zero" );
return aShortName ? wxString( wxT( "PZ" ) )
: _( "Pole-zero" );
case ST_SENSITIVITY:
return aShortName ? wxT( "SENS" ) : _( "Sensitivity" );
return aShortName ? wxString( wxT( "SENS" ) )
: _( "Sensitivity" );
case ST_TRANS_FUNC:
return aShortName ? wxT( "TF" ) : _( "Transfer function" );
return aShortName ? wxString( wxT( "TF" ) )
: _( "Transfer function" );
default:
case ST_UNKNOWN:

View File

@ -156,7 +156,7 @@ bool SYMBOL_TREE_MODEL_ADAPTER::AddLibraries( const std::vector<wxString>& aNick
for( const wxString& lib : subLibraries )
{
wxString suffix = lib.IsEmpty() ? wxT( "" )
wxString suffix = lib.IsEmpty() ? wxString( wxT( "" ) )
: wxString::Format( wxT( " - %s" ), lib );
wxString name = wxString::Format( wxT( "%s%s" ), pair.first, suffix );
wxString desc;

View File

@ -692,7 +692,7 @@ bool SYMBOL_VIEWER_FRAME::ReCreateLibList()
for( const wxString& lib : subLibraries )
{
wxString suffix = lib.IsEmpty() ? wxT( "" )
wxString suffix = lib.IsEmpty() ? wxString( wxT( "" ) )
: wxString::Format( wxT( " - %s" ), lib );
wxString name = wxString::Format( wxT( "%s%s" ), aLib, suffix );
@ -749,7 +749,7 @@ bool SYMBOL_VIEWER_FRAME::ReCreateLibList()
// If not found, clear current library selection because it can be deleted after a
// config change.
m_currentSymbol.SetLibNickname( m_libList->GetCount() > 0
? m_libList->GetBaseString( 0 ) : wxT( "" ) );
? m_libList->GetBaseString( 0 ) : wxString( wxT( "" ) ) );
m_currentSymbol.SetLibItemName( wxEmptyString );
m_unit = 1;
m_convert = LIB_ITEM::LIB_CONVERT::BASE;

View File

@ -130,7 +130,7 @@ int GERBVIEW_INSPECTION_TOOL::ShowDCodes( const TOOL_EVENT& aEvent )
pt_D_code->m_Size.y / scale, units,
pt_D_code->m_Size.x / scale, units,
D_CODE::ShowApertureType( pt_D_code->m_ApertType ),
pt_D_code->m_AperFunction.IsEmpty()? wxT( "none" ) : pt_D_code->m_AperFunction
pt_D_code->m_AperFunction.IsEmpty()? wxString( wxT( "none" ) ) : pt_D_code->m_AperFunction
);
if( !pt_D_code->m_Defined )

View File

@ -888,7 +888,7 @@ const wxString PLUGIN_CONTENT_MANAGER::GetPackageUpdateVersion( const PCM_PACKAG
&& installed_ver_it->parsed_version < ver.parsed_version;
} );
return ver_it == aPackage.versions.end() ? wxT( "" ) : ver_it->version;
return ver_it == aPackage.versions.end() ? wxString( wxT( "" ) ) : ver_it->version;
}
time_t PLUGIN_CONTENT_MANAGER::getCurrentTimestamp() const

View File

@ -226,12 +226,12 @@ void PANEL_TRANSLINE::TranslineTypeSelection( enum TRANSLINE_TYPE_ID aType )
wxASSERT ( data );
data->name->SetToolTip( prm->m_ToolTip );
data->name->SetLabel( prm->m_DlgLabel != "" ? prm->m_DlgLabel + ':' : "" );
data->name->SetLabel( prm->m_DlgLabel != wxS( "" ) ? prm->m_DlgLabel + wxS( ':' ) : wxString( wxS( "" ) ) );
prm->m_ValueCtrl = data->value;
if( prm->m_Id != DUMMY_PRM )
{
data->value->SetValue( wxString::Format( "%g", prm->m_Value ) );
data->value->SetValue( wxString::Format( wxS( "%g" ), prm->m_Value ) );
data->value->Enable( true );
}
else

View File

@ -135,7 +135,7 @@ void SpreadFootprints( std::vector<FOOTPRINT*>* aFootprints, VECTOR2I aTargetBox
for( FOOTPRINT* footprint : *aFootprints )
{
wxString path =
aGroupBySheet ? footprint->GetPath().AsString().BeforeLast( '/' ) : wxS( "" );
aGroupBySheet ? footprint->GetPath().AsString().BeforeLast( '/' ) : wxString( wxS( "" ) );
VECTOR2I size = footprint->GetBoundingBox( false, false ).GetSize();
size.x += aComponentGap;

View File

@ -532,7 +532,7 @@ void DIALOG_BOARD_REANNOTATE::LogChangePlan()
change.NewRefDes,
ActionMessage[change.Action],
UpdateRefDes != change.Action ? _( " will be ignored" )
: wxT( "" ) );
: wxString( wxT( "" ) ) );
}
ShowReport( message, RPT_SEVERITY_INFO );

View File

@ -292,7 +292,7 @@ void DIALOG_EXPORT_SVG::ExportSVGFile( bool aOnlyOneFile )
{
PCB_LAYER_ID layer = *seq;
wxFileName fn( boardFilename );
wxString suffix = aOnlyOneFile ? wxT( "brd" ) : m_board->GetStandardLayerName( layer );
wxString suffix = aOnlyOneFile ? wxString( wxT( "brd" ) ) : m_board->GetStandardLayerName( layer );
BuildPlotFileName( &fn, outputDir.GetPath(), suffix, SVGFileExtension );
wxString svgPath = fn.GetFullPath();

View File

@ -714,7 +714,7 @@ void CADSTAR_PCB_ARCHIVE_LOADER::loadComponentLibrary()
SYMDEF_PCB component = symPair.second;
wxString fpName = component.ReferenceName + ( ( component.Alternate.size() > 0 ) ?
( wxT( " (" ) + component.Alternate + wxT( ")" ) ) :
wxT( "" ) );
wxString( wxT( "" ) ) );
// Check that we are not loading a documentation symbol.
// Documentation symbols in CADSTAR are graphical "footprints" that can be assigned

View File

@ -2140,7 +2140,7 @@ void PCB_PLUGIN::format( const ZONE* aZone, int aNestLevel ) const
m_out->Print( aNestLevel, "(zone%s (net %d) (net_name %s)",
locked.c_str(),
has_no_net ? 0 : m_mapping->Translate( aZone->GetNetCode() ),
m_out->Quotew( has_no_net ? wxT("") : aZone->GetNetname() ).c_str() );
m_out->Quotew( has_no_net ? wxString( wxT("") ) : aZone->GetNetname() ).c_str() );
// If a zone exists on multiple layers, format accordingly
if( aZone->GetLayerSet().count() > 1 )

View File

@ -294,7 +294,7 @@ void DRAWING_TOOL::UpdateStatusBar() const
else
constrained = mgr.GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>()->m_Use45Limit;
m_frame->DisplayConstraintsMsg( constrained ? _( "Constrain to H, V, 45" ) : wxT( "" ) );
m_frame->DisplayConstraintsMsg( constrained ? _( "Constrain to H, V, 45" ) : wxString( wxT( "" ) ) );
}
}

View File

@ -345,7 +345,7 @@ int EDIT_TOOL::doMoveSelection( const TOOL_EVENT& aEvent, const wxString& aCommi
[editFrame]( bool constrained )
{
editFrame->DisplayConstraintsMsg( constrained ? _( "Constrain to H, V, 45" )
: wxT( "" ) );
: wxString( wxT( "" ) ) );
};
auto updateStatusPopup =