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;
// 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;
// Save the position
@ -1158,12 +1158,12 @@ bool SCH_COMPONENT::Load( LINE_READER& aLine, wxString& aErrorMsg )
// which are UTF8 encoded, because sscanf does not work well on Windows
// with some UTF8 values.
int ii;
char name1[256],
char1[256], char2[256], char3[256];
char name1[256], char1[256], char2[256], char3[256];
int newfmt = 0;
char* ptcar;
wxString fieldName;
char* line = aLine.Line();
unsigned long timeStamp;
m_convert = 1;
@ -1264,7 +1264,8 @@ bool SCH_COMPONENT::Load( LINE_READER& aLine, wxString& aErrorMsg )
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' )
{

View File

@ -142,7 +142,7 @@ bool SCH_SHEET::Save( FILE* aFile ) const
return false;
//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;
/* Save schematic sheetname and filename. */
@ -180,6 +180,7 @@ bool SCH_SHEET::Load( LINE_READER& aLine, wxString& aErrorMsg )
int fieldNdx, size;
SCH_SHEET_PIN* sheetPin;
char* ptcar;
unsigned long timeStamp = 0UL;
SetTimeStamp( GetNewTimeStamp() );
@ -219,9 +220,13 @@ bool SCH_SHEET::Load( LINE_READER& aLine, wxString& aErrorMsg )
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!
SetTimeStamp( GetNewTimeStamp() );
continue;
}

View File

@ -2301,7 +2301,7 @@ void LEGACY_PLUGIN::loadTrackList( int aStructType )
#endif
int makeType;
time_t timeStamp;
unsigned long timeStamp;
LAYER_NUM layer_num;
int type, net_code, flags_int;
@ -2337,8 +2337,7 @@ void LEGACY_PLUGIN::loadTrackList( int aStructType )
break;
}
newTrack->SetTimeStamp( timeStamp );
newTrack->SetTimeStamp( (time_t)timeStamp );
newTrack->SetPosition( wxPoint( start_x, start_y ) );
newTrack->SetEnd( wxPoint( end_x, end_y ) );
@ -2784,7 +2783,7 @@ void LEGACY_PLUGIN::loadDIMENSION()
else if( TESTLINE( "Ge" ) )
{
LAYER_NUM layer_num;
time_t timestamp;
unsigned long timestamp;
int shape;
int ilayer;
@ -2798,7 +2797,7 @@ void LEGACY_PLUGIN::loadDIMENSION()
layer_num = ilayer;
dim->SetLayer( leg_layer2new( m_cu_count, layer_num ) );
dim->SetTimeStamp( timestamp );
dim->SetTimeStamp( (time_t) timestamp );
dim->SetShape( shape );
}

View File

@ -8,7 +8,7 @@
* Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2013 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* 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
* modify it under the terms of the GNU General Public License
@ -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 )
{
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()
{
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 )
{
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()
{
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,
const FPID& aNewFootprintFPID,
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 )
{
wxString newname;
@ -542,7 +503,7 @@ bool RecreateCmpFile( BOARD * aBrd, const wxString& aFullCmpFileName )
for( ; module != NULL; module = module->Next() )
{
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, "Reference = %s;\n",
!module->GetReference().IsEmpty() ?