Remove `using namespace std` to fix building with mingw-w64
Using `using namespace std;` is a bad practice, especially in header files as it can lead to name collisions. In this case `std::byte` (from C++ 17) collided with `typedef unsigned char byte` (from the Windows header `rpcndr.h`) leading to many build errors.
This commit is contained in:
parent
3f482e49c7
commit
fab9af593e
|
@ -80,7 +80,7 @@ void CMidiFile::openMidiFile(const std::string &filename)
|
|||
m_file.close();
|
||||
m_file.clear(); // clear any errors
|
||||
|
||||
m_file.open(filename.c_str(), ios_base::in | ios_base::binary);
|
||||
m_file.open(filename.c_str(), std::ios_base::in | std::ios_base::binary);
|
||||
if (m_file.fail() == true)
|
||||
{
|
||||
QMessageBox::warning(nullptr, QMessageBox::tr("MIDI File Error"),
|
||||
|
@ -98,12 +98,12 @@ void CMidiFile::rewind()
|
|||
{
|
||||
m_numberOfTracks = 0;
|
||||
dword_t trackLength;
|
||||
streampos filePos;
|
||||
std::streampos filePos;
|
||||
|
||||
midiError(SMF_NO_ERROR);
|
||||
m_ppqn = DEFAULT_PPQN;
|
||||
|
||||
m_file.seekg (0, ios::beg);
|
||||
m_file.seekg (0, std::ios::beg);
|
||||
|
||||
const auto ntrks = readHeader();
|
||||
if (ntrks == 0)
|
||||
|
@ -137,8 +137,8 @@ void CMidiFile::rewind()
|
|||
break;
|
||||
}
|
||||
//now move onto the next track
|
||||
filePos += static_cast<streamoff>(trackLength);
|
||||
m_file.seekg (filePos, ios::beg);
|
||||
filePos += static_cast<std::streamoff>(trackLength);
|
||||
m_file.seekg (filePos, std::ios::beg);
|
||||
}
|
||||
m_songTitle = m_tracks[0]->getTrackName();
|
||||
initMergedEvents();
|
||||
|
|
|
@ -36,8 +36,6 @@
|
|||
#include "Merge.h"
|
||||
|
||||
#define DEFAULT_PPQN 96 /* Standard value for pulse per quarter note */
|
||||
|
||||
using namespace std;
|
||||
#define MAX_TRACKS 40
|
||||
|
||||
// Reads data from a standard MIDI file
|
||||
|
@ -72,7 +70,7 @@ private:
|
|||
bool checkMidiEventFromStream(int streamIdx);
|
||||
CMidiEvent fetchMidiEventFromStream(int streamIdx);
|
||||
void midiError(midiErrors_t error) {m_midiError = error;}
|
||||
fstream m_file;
|
||||
std::fstream m_file;
|
||||
static int m_ppqn;
|
||||
midiErrors_t m_midiError;
|
||||
CMidiTrack* m_tracks[MAX_TRACKS];
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
|
||||
int CMidiTrack::m_logLevel;
|
||||
|
||||
CMidiTrack::CMidiTrack(fstream& file, int no) :m_file(file), m_trackNumber(no)
|
||||
CMidiTrack::CMidiTrack(std::fstream& file, int no) :m_file(file), m_trackNumber(no)
|
||||
{
|
||||
m_trackEventQueue = nullptr;
|
||||
m_savedRunningStatus = 0;
|
||||
|
@ -122,11 +122,11 @@ dword_t CMidiTrack::readVarLen()
|
|||
return ( value );
|
||||
}
|
||||
|
||||
string CMidiTrack::readTextEvent()
|
||||
std::string CMidiTrack::readTextEvent()
|
||||
{
|
||||
dword_t length;
|
||||
|
||||
string text;
|
||||
std::string text;
|
||||
length = readVarLen();
|
||||
if (length >= 1000)
|
||||
{
|
||||
|
@ -250,7 +250,7 @@ void CMidiTrack::readKeySignatureEvent()
|
|||
|
||||
void CMidiTrack::readMetaEvent(byte_t type)
|
||||
{
|
||||
string text;
|
||||
std::string text;
|
||||
__dt(dword_t data);
|
||||
|
||||
if (failed() == true)
|
||||
|
@ -517,7 +517,7 @@ void CMidiTrack::decodeTrack()
|
|||
{
|
||||
CMidiEvent event;
|
||||
|
||||
m_file.seekg(m_filePos, ios::beg);
|
||||
m_file.seekg(m_filePos, std::ios::beg);
|
||||
while (true)
|
||||
{
|
||||
if (m_trackLengthCounter== 0)
|
||||
|
|
|
@ -34,8 +34,6 @@
|
|||
#include "Queue.h"
|
||||
#include "MidiEvent.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SMF_NO_ERROR,
|
||||
|
@ -54,7 +52,7 @@ typedef unsigned long dword_t;
|
|||
class CMidiTrack
|
||||
{
|
||||
public:
|
||||
CMidiTrack(fstream& file, int no);
|
||||
CMidiTrack(std::fstream& file, int no);
|
||||
|
||||
~CMidiTrack()
|
||||
{
|
||||
|
@ -135,7 +133,7 @@ private:
|
|||
void decodeMidiEvent();
|
||||
dword_t readVarLen();
|
||||
|
||||
string readTextEvent();
|
||||
std::string readTextEvent();
|
||||
dword_t readDataEvent(int expectedLength);
|
||||
void readMetaEvent(byte_t type);
|
||||
void ignoreSysexEvent(byte_t data);
|
||||
|
@ -156,10 +154,10 @@ private:
|
|||
}
|
||||
}
|
||||
|
||||
fstream& m_file;
|
||||
std::fstream& m_file;
|
||||
int m_trackNumber;
|
||||
|
||||
streampos m_filePos;
|
||||
std::streampos m_filePos;
|
||||
dword_t m_trackLength;
|
||||
dword_t m_trackLengthCounter;
|
||||
CQueue<CMidiEvent>* m_trackEventQueue;
|
||||
|
|
|
@ -56,7 +56,7 @@ void CSong::loadSong(const QString & filename)
|
|||
fn = fn.replace('/','\\');
|
||||
#endif
|
||||
m_midiFile->setLogLevel(3);
|
||||
m_midiFile->openMidiFile(string(fn.toLocal8Bit().data()));
|
||||
m_midiFile->openMidiFile(std::string(fn.toLocal8Bit().data()));
|
||||
ppLogInfo("Opening song %s", fn.toLocal8Bit().data());
|
||||
transpose(0);
|
||||
midiFileInfo();
|
||||
|
@ -266,7 +266,7 @@ bool CSong::pcKeyPress(int key, bool down)
|
|||
return true;
|
||||
}
|
||||
|
||||
for (j = 0; j < arraySize(pcNoteLookup); j++)
|
||||
for (j = 0; j < arraySizeAs<std::size_t>(pcNoteLookup); j++)
|
||||
{
|
||||
if ( key==pcNoteLookup[j].key)
|
||||
{
|
||||
|
|
|
@ -36,8 +36,6 @@
|
|||
#include <QString>
|
||||
#include <QApplication>
|
||||
|
||||
using namespace std;
|
||||
|
||||
#define MAX_MIDI_CHANNELS 16 // There are always at most 16 midi channels
|
||||
#define MIDDLE_C 60
|
||||
#define MIDI_OCTAVE 12
|
||||
|
|
Loading…
Reference in New Issue