MinGW64 build warning fixes.

* On MinGW64 and possibly other 64-bit platforms, time_t is defined as a long
  long unsigned integer but all of the scanf and printf format specifiers used
  to save and load the schematic files are %lX which is a long unsigned integer
  which causes compile warnings.  Add casts and temporary variables to eliminate
  the compile type warnings.
This commit is contained in:
Wayne Stambaugh 2016-03-14 14:20:19 -04:00
parent 44fc6cb337
commit b7c974b2c4
4 changed files with 32 additions and 66 deletions

View File

@ -1073,7 +1073,7 @@ bool SCH_COMPONENT::Save( FILE* f ) const
return false; return false;
// Generate unit number, convert and time stamp // Generate unit number, convert and time stamp
if( fprintf( f, "U %d %d %8.8lX\n", m_unit, m_convert, m_TimeStamp ) == EOF ) if( fprintf( f, "U %d %d %8.8lX\n", m_unit, m_convert, (unsigned long)m_TimeStamp ) == EOF )
return false; return false;
// Save the position // Save the position
@ -1157,13 +1157,13 @@ bool SCH_COMPONENT::Load( LINE_READER& aLine, wxString& aErrorMsg )
// Remark: avoid using sscanf to read texts entered by user // Remark: avoid using sscanf to read texts entered by user
// which are UTF8 encoded, because sscanf does not work well on Windows // which are UTF8 encoded, because sscanf does not work well on Windows
// with some UTF8 values. // with some UTF8 values.
int ii; int ii;
char name1[256], char name1[256], char1[256], char2[256], char3[256];
char1[256], char2[256], char3[256]; int newfmt = 0;
int newfmt = 0; char* ptcar;
char* ptcar; wxString fieldName;
wxString fieldName; char* line = aLine.Line();
char* line = aLine.Line(); unsigned long timeStamp;
m_convert = 1; m_convert = 1;
@ -1264,7 +1264,8 @@ bool SCH_COMPONENT::Load( LINE_READER& aLine, wxString& aErrorMsg )
if( line[0] == 'U' ) if( line[0] == 'U' )
{ {
sscanf( line + 1, "%d %d %lX", &m_unit, &m_convert, &m_TimeStamp ); sscanf( line + 1, "%d %d %lX", &m_unit, &m_convert, &timeStamp );
m_TimeStamp = (time_t)timeStamp;
} }
else if( line[0] == 'P' ) else if( line[0] == 'P' )
{ {

View File

@ -142,7 +142,7 @@ bool SCH_SHEET::Save( FILE* aFile ) const
return false; return false;
//save the unique timestamp, like other schematic parts. //save the unique timestamp, like other schematic parts.
if( fprintf( aFile, "U %8.8lX\n", m_TimeStamp ) == EOF ) if( fprintf( aFile, "U %8.8lX\n", (unsigned long) m_TimeStamp ) == EOF )
return false; return false;
/* Save schematic sheetname and filename. */ /* Save schematic sheetname and filename. */
@ -180,6 +180,7 @@ bool SCH_SHEET::Load( LINE_READER& aLine, wxString& aErrorMsg )
int fieldNdx, size; int fieldNdx, size;
SCH_SHEET_PIN* sheetPin; SCH_SHEET_PIN* sheetPin;
char* ptcar; char* ptcar;
unsigned long timeStamp = 0UL;
SetTimeStamp( GetNewTimeStamp() ); SetTimeStamp( GetNewTimeStamp() );
@ -219,9 +220,13 @@ bool SCH_SHEET::Load( LINE_READER& aLine, wxString& aErrorMsg )
if( ((char*)aLine)[0] == 'U' ) if( ((char*)aLine)[0] == 'U' )
{ {
sscanf( ((char*)aLine) + 1, "%lX", &m_TimeStamp ); sscanf( ((char*)aLine) + 1, "%lX", &timeStamp );
m_TimeStamp = (time_t) timeStamp;
if( m_TimeStamp == 0 ) // zero is not unique! if( m_TimeStamp == 0 ) // zero is not unique!
SetTimeStamp( GetNewTimeStamp() ); SetTimeStamp( GetNewTimeStamp() );
continue; continue;
} }

View File

@ -2300,10 +2300,10 @@ void LEGACY_PLUGIN::loadTrackList( int aStructType )
} }
#endif #endif
int makeType; int makeType;
time_t timeStamp; unsigned long timeStamp;
LAYER_NUM layer_num; LAYER_NUM layer_num;
int type, net_code, flags_int; int type, net_code, flags_int;
// parse the 2nd line to determine the type of object // parse the 2nd line to determine the type of object
// e.g. "De 15 1 7 0 0" for a via // e.g. "De 15 1 7 0 0" for a via
@ -2337,8 +2337,7 @@ void LEGACY_PLUGIN::loadTrackList( int aStructType )
break; break;
} }
newTrack->SetTimeStamp( timeStamp ); newTrack->SetTimeStamp( (time_t)timeStamp );
newTrack->SetPosition( wxPoint( start_x, start_y ) ); newTrack->SetPosition( wxPoint( start_x, start_y ) );
newTrack->SetEnd( wxPoint( end_x, end_y ) ); newTrack->SetEnd( wxPoint( end_x, end_y ) );
@ -2783,10 +2782,10 @@ void LEGACY_PLUGIN::loadDIMENSION()
else if( TESTLINE( "Ge" ) ) else if( TESTLINE( "Ge" ) )
{ {
LAYER_NUM layer_num; LAYER_NUM layer_num;
time_t timestamp; unsigned long timestamp;
int shape; int shape;
int ilayer; int ilayer;
sscanf( line + SZ( "Ge" ), " %d %d %lX", &shape, &ilayer, &timestamp ); sscanf( line + SZ( "Ge" ), " %d %d %lX", &shape, &ilayer, &timestamp );
@ -2798,7 +2797,7 @@ void LEGACY_PLUGIN::loadDIMENSION()
layer_num = ilayer; layer_num = ilayer;
dim->SetLayer( leg_layer2new( m_cu_count, layer_num ) ); dim->SetLayer( leg_layer2new( m_cu_count, layer_num ) );
dim->SetTimeStamp( timestamp ); dim->SetTimeStamp( (time_t) timestamp );
dim->SetShape( shape ); dim->SetShape( shape );
} }

View File

@ -8,7 +8,7 @@
* Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2013 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com> * Copyright (C) 2013 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2013 Wayne Stambaugh <stambaughw@verizon.net> * Copyright (C) 2013 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -120,15 +120,15 @@ void DIALOG_EXCHANGE_MODULE::init()
m_CmpValue->AppendText( m_currentModule->GetValue() ); m_CmpValue->AppendText( m_currentModule->GetValue() );
m_CmpReference->AppendText( m_currentModule->GetReference() ); m_CmpReference->AppendText( m_currentModule->GetReference() );
m_Selection->SetString( 0, wxString::Format( m_Selection->SetString( 0, wxString::Format(
_("Change footprint of '%s'" ), _( "Change footprint of '%s'" ),
GetChars( m_currentModule->GetReference() ) ) ); GetChars( m_currentModule->GetReference() ) ) );
wxString fpname = m_CurrentFootprintFPID->GetValue().AfterLast(':'); wxString fpname = m_CurrentFootprintFPID->GetValue().AfterLast( ':' );
if( fpname.IsEmpty() ) // Happens for old fp names if( fpname.IsEmpty() ) // Happens for old fp names
fpname = m_CurrentFootprintFPID->GetValue(); fpname = m_CurrentFootprintFPID->GetValue();
m_Selection->SetString( 1, wxString::Format( m_Selection->SetString( 1, wxString::Format(
_("Change footprints '%s'" ), _( "Change footprints '%s'" ),
GetChars( fpname.Left( 12 ) ) ) ); GetChars( fpname.Left( 12 ) ) ) );
m_Selection->SetSelection( m_selectionMode ); m_Selection->SetSelection( m_selectionMode );
@ -198,11 +198,6 @@ void DIALOG_EXCHANGE_MODULE::OnSelectionClicked( wxCommandEvent& event )
} }
/*
* Rebuild the file name.CMP (if any) after exchanging footprints
* if the footprint are managed by this file
* Return false if error
*/
void DIALOG_EXCHANGE_MODULE::RebuildCmpList( wxCommandEvent& event ) void DIALOG_EXCHANGE_MODULE::RebuildCmpList( wxCommandEvent& event )
{ {
wxFileName fn; wxFileName fn;
@ -227,12 +222,6 @@ void DIALOG_EXCHANGE_MODULE::RebuildCmpList( wxCommandEvent& event )
} }
/* Change the current footprint at the current cursor position.
* Retains the following:
* - position, orientation and side
* - value and ref
* - pads net names
*/
bool DIALOG_EXCHANGE_MODULE::changeCurrentFootprint() bool DIALOG_EXCHANGE_MODULE::changeCurrentFootprint()
{ {
wxString newmodulename = m_NewFootprintFPID->GetValue(); wxString newmodulename = m_NewFootprintFPID->GetValue();
@ -244,17 +233,6 @@ bool DIALOG_EXCHANGE_MODULE::changeCurrentFootprint()
} }
/*
* Change all footprints having the same fpid by a new one from lib
* Retains:
* - direction, position, side
* - value and ref
* - pads net names
* Note: m_currentModule is no longer the current footprint
* since it has been changed!
* if aUseValue is true, footprints having the same fpid should
* also have the same value
*/
bool DIALOG_EXCHANGE_MODULE::changeSameFootprints( bool aUseValue ) bool DIALOG_EXCHANGE_MODULE::changeSameFootprints( bool aUseValue )
{ {
wxString msg; wxString msg;
@ -325,13 +303,6 @@ bool DIALOG_EXCHANGE_MODULE::changeSameFootprints( bool aUseValue )
} }
/*
* Change all modules with module of the same name in library.
* Maintains:
* - direction, position, side
* - value and ref
* - pads net names
*/
bool DIALOG_EXCHANGE_MODULE::changeAllFootprints() bool DIALOG_EXCHANGE_MODULE::changeAllFootprints()
{ {
MODULE* Module, * PtBack; MODULE* Module, * PtBack;
@ -366,15 +337,6 @@ bool DIALOG_EXCHANGE_MODULE::changeAllFootprints()
} }
/*
* Change aModule to a new, fresh one from lib
* Retains
* - direction, position, side
* - value and ref
* - pads net names
* Returns: false if no change (if the new module is not found)
* true if OK
*/
bool DIALOG_EXCHANGE_MODULE::change_1_Module( MODULE* aModule, bool DIALOG_EXCHANGE_MODULE::change_1_Module( MODULE* aModule,
const FPID& aNewFootprintFPID, const FPID& aNewFootprintFPID,
bool aShowError ) bool aShowError )
@ -473,7 +435,6 @@ void DIALOG_EXCHANGE_MODULE::BrowseAndSelectFootprint( wxCommandEvent& event )
} }
// Runs the footprint viewer to select a footprint.
void DIALOG_EXCHANGE_MODULE::ViewAndSelectFootprint( wxCommandEvent& event ) void DIALOG_EXCHANGE_MODULE::ViewAndSelectFootprint( wxCommandEvent& event )
{ {
wxString newname; wxString newname;
@ -542,7 +503,7 @@ bool RecreateCmpFile( BOARD * aBrd, const wxString& aFullCmpFileName )
for( ; module != NULL; module = module->Next() ) for( ; module != NULL; module = module->Next() )
{ {
fprintf( cmpFile, "\nBeginCmp\n" ); fprintf( cmpFile, "\nBeginCmp\n" );
fprintf( cmpFile, "TimeStamp = %8.8lX\n", module->GetTimeStamp() ); fprintf( cmpFile, "TimeStamp = %8.8lX\n", (unsigned long)module->GetTimeStamp() );
fprintf( cmpFile, "Path = %s\n", TO_UTF8( module->GetPath() ) ); fprintf( cmpFile, "Path = %s\n", TO_UTF8( module->GetPath() ) );
fprintf( cmpFile, "Reference = %s;\n", fprintf( cmpFile, "Reference = %s;\n",
!module->GetReference().IsEmpty() ? !module->GetReference().IsEmpty() ?