cleanup CMAKE_CXX_FLAGS and fix various warnings

This commit is contained in:
Wolfgang Thaller 2019-01-04 03:35:32 +01:00
parent bade105326
commit 380fef0114
26 changed files with 268 additions and 272 deletions

View File

@ -22,6 +22,8 @@ set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED TRUE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror=return-type -Wno-multichar")
if(CMAKE_SYSTEM_NAME MATCHES Retro.*)

View File

@ -16,7 +16,6 @@
# along with Retro68. If not, see <http://www.gnu.org/licenses/>.
cmake_minimum_required(VERSION 2.8)
set(CMAKE_CXX_FLAGS "-std=c++11")
add_library(RetroConsole
Console.cc
@ -30,6 +29,12 @@ set_target_properties(retrocrt
PROPERTIES
COMPILE_OPTIONS -ffunction-sections)
# different library name for Carbon
# (Carbon shares the powerpc-apple-macos/ directory with Classic PPC)
if(CMAKE_SYSTEM_NAME MATCHES RetroCarbon)
set_target_properties(RetroConsole PROPERTIES OUTPUT_NAME RetroConsoleCarbon)
endif()
install(TARGETS RetroConsole DESTINATION lib)
add_application(ConsoleTest

View File

@ -19,7 +19,6 @@
#include "Console.h"
#include "MacUtils.h"
#include "Events.h"
#include "Fonts.h"
#include "Processes.h"
@ -254,7 +253,6 @@ void Console::write(const char *p, int n)
std::string Console::ReadLine()
{
std::string buffer;
EventRecord event;
char c;
do

View File

@ -1,5 +1,3 @@
set(CMAKE_CXX_FLAGS "--std=c++11 -Wall -Werror=return-type -Wno-multichar")
find_package(Boost COMPONENTS filesystem system REQUIRED)
add_executable(ConvertObj ConvertObj.cc)

View File

@ -46,6 +46,7 @@ public:
/*
* Recursive directory copy from https://stackoverflow.com/a/39146566
*/
#ifdef __APPLE__
static void copyDirectoryRecursively(const fs::path& sourceDir, const fs::path& destinationDir)
{
if (!fs::exists(sourceDir) || !fs::is_directory(sourceDir))
@ -68,6 +69,7 @@ static void copyDirectoryRecursively(const fs::path& sourceDir, const fs::path&
fs::copy(path, destinationDir / relativePathStr);
}
}
#endif
MiniVMacLauncher::MiniVMacLauncher(po::variables_map &options)
: Launcher(options),
@ -286,6 +288,8 @@ void MiniVMacLauncher::DumpOutput()
vol = hfs_mount(imagePath.string().c_str(), 0, HFS_MODE_RDONLY);
hfsdirent fileent;
int statres = hfs_stat(vol, "out", &fileent);
if(statres)
return;
hfsfile *out = hfs_open(vol, "out");
if(!out)

View File

@ -46,7 +46,7 @@ public:
private:
void write(const void *p, size_t n);
ssize_t read(void * p, size_t n);
size_t read(void * p, size_t n);
};
@ -140,10 +140,10 @@ SerialLauncher::~SerialLauncher()
{
}
ssize_t SerialLauncher::read(void *p0, size_t n)
size_t SerialLauncher::read(void *p0, size_t n)
{
uint8_t* p = (uint8_t*)p0;
ssize_t gotBytes = rStream.read(p, n);
size_t gotBytes = rStream.read(p, n);
while(gotBytes < n)
{
rStream.flushWrite();

View File

@ -94,7 +94,7 @@ TCPLauncher::~TCPLauncher()
ssize_t TCPLauncher::read(void *p0, size_t n)
{
uint8_t* p = (uint8_t*)p0;
ssize_t gotBytes = rStream.read(p, n);
size_t gotBytes = rStream.read(p, n);
while(gotBytes < n)
{
rStream.flushWrite();

View File

@ -11,6 +11,6 @@ target_include_directories(LaunchAPPLCommon PUBLIC .)
add_executable(TestLaunchAPPLCommon Test.cc)
target_link_libraries(TestLaunchAPPLCommon LaunchAPPLCommon)
if(CMAKE_SYSTEM_NAME MATCHES Retro68)
#target_compile_options(LaunchAPPLCommon PRIVATE -ffunction-sections -fno-exceptions -Os)
if(CMAKE_SYSTEM_NAME MATCHES Retro)
target_compile_options(LaunchAPPLCommon PRIVATE -ffunction-sections -Os)
endif()

View File

@ -95,7 +95,7 @@ void ReliableStream::gotAck(uint8_t id)
if(nAcked <= sentPackets.size())
{
ackedOutputPacket += nAcked;
for(int i = 0; i < nAcked; i++)
for(unsigned i = 0; i < nAcked; i++)
sentPackets.pop_front();
sendPackets();
@ -110,7 +110,7 @@ void ReliableStream::gotNack(uint8_t id)
if(nAcked <= sentPackets.size())
{
ackedOutputPacket += nAcked;
for(int i = 0; i < nAcked; i++)
for(unsigned i = 0; i < nAcked; i++)
sentPackets.pop_front();
sentOutputPacket = ackedOutputPacket;
@ -171,8 +171,8 @@ void ReliableStream::sendOnePacket()
};
int match = 0, match2 = 0;
int i;
int consumed = 0;
size_t i;
size_t consumed = 0;
for(i = 0; i < n; i++)
{
if(p[i] == magic1[match])
@ -390,8 +390,8 @@ size_t ReliableStream::onReceive(const uint8_t* p, size_t n)
case State::skipping:
{
int match = 0;
int i;
unsigned match = 0;
unsigned i;
for(i = 0; i < n; i++)
{
if(p[i] == magic1[match++])
@ -401,7 +401,6 @@ size_t ReliableStream::onReceive(const uint8_t* p, size_t n)
state = State::waiting;
return i-3;
}
}
else
match = 0;
@ -412,9 +411,7 @@ size_t ReliableStream::onReceive(const uint8_t* p, size_t n)
case State::receiving:
{
int i;
for(i = 0; i < n; i++)
for(unsigned i = 0; i < n; i++)
{
incomingPacket.push_back(p[i]);
@ -461,5 +458,5 @@ size_t ReliableStream::onReceive(const uint8_t* p, size_t n)
}
break;
}
assert(false);
std::abort(); // unreachable
}

View File

@ -38,7 +38,7 @@ void Stream::notifyReset()
listener_->onReset();
}
long Stream::read(void *p, size_t n)
size_t Stream::read(void *p, size_t n)
{
if(buffer_.size() <= n)
{

View File

@ -25,7 +25,7 @@ public:
virtual void write(const void* p, size_t n) = 0;
virtual void flushWrite() {}
long read(void *p, size_t n);
size_t read(void *p, size_t n);
virtual bool readyToWrite() const { return true; }
bool readyToRead() const { return !buffer_.empty(); }

View File

@ -15,7 +15,7 @@ public:
virtual void write(const void* p, size_t n)
{
std::cout << prefix << ": ";
for(int i = 0; i < n; i++)
for(size_t i = 0; i < n; i++)
std::cout << std::hex << std::setfill('0') << std::setw(2) << (int) ((uint8_t*)p)[i] << " ";
std::cout << std::endl;
other->enqueueReceive(p,n);
@ -45,7 +45,7 @@ public:
size_t onReceive(const uint8_t* p, size_t n)
{
std::cout << prefix;
for(int i = 0; i < n; i++)
for(size_t i = 0; i < n; i++)
{
if(p[i] >= 128 || p[i] < 32)
std::cout << "\\x" << std::hex << (unsigned)p[i];

View File

@ -51,7 +51,7 @@ target_link_libraries(LaunchAPPLServer LaunchAPPLCommon)
set_target_properties(LaunchAPPLServer PROPERTIES
CXX_STANDARD 17
)
target_compile_options(LaunchAPPLServer PRIVATE -ffunction-sections -Os) # -fno-exceptions
target_compile_options(LaunchAPPLServer PRIVATE -ffunction-sections -Os)
if(CMAKE_SYSTEM_NAME MATCHES Retro68)
set_target_properties(LaunchAPPLServer PROPERTIES
LINK_FLAGS "-Wl,-gc-sections -Wl,--mac-segments -Wl,${CMAKE_CURRENT_SOURCE_DIR}/LaunchAPPLServer.segmap"

View File

@ -375,6 +375,9 @@ public:
state = State::launch;
return count;
}
default:
return 0;
}
}
@ -412,8 +415,10 @@ public:
else
{
connection->suspend();
#if TARGET_CPU_68K
if(void *seg = connection->segmentToUnload())
UnloadSeg(seg);
#endif
gPrefs.inSubLaunch = true;
WritePrefs();
@ -482,7 +487,7 @@ public:
memset(&lpb, 0, sizeof(lpb));
lpb.reserved1 = (unsigned long) LMGetCurApName();
lpb.reserved2 = 0;
OSErr err = LaunchApplication(&lpb);
LaunchApplication(&lpb);
ExitToShell();
}
onReset();
@ -552,6 +557,8 @@ void ConnectionChanged()
connection = std::make_unique<OpenTptConnectionProvider>(statusDisplay.get());;
break;
#endif
default:
;
}
if(connection)
@ -599,7 +606,6 @@ int main()
#if TARGET_CPU_68K && !TARGET_RT_MAC_CFM
short& ROM85 = *(short*) 0x028E;
Boolean is128KROM = (ROM85 > 0);
Boolean hasSysEnvirons = false;
Boolean hasWaitNextEvent = false;
Boolean hasGestalt = false;
Boolean hasAppleEvents = false;
@ -609,11 +615,9 @@ int main()
if (is128KROM)
{
UniversalProcPtr trapUnimpl = GetToolTrapAddress(_Unimplemented);
UniversalProcPtr trapSysEnv = GetOSTrapAddress(_SysEnvirons);
UniversalProcPtr trapWaitNextEvent = GetToolTrapAddress(_WaitNextEvent);
UniversalProcPtr trapGestalt = GetOSTrapAddress(_Gestalt);
hasSysEnvirons = (trapSysEnv != trapUnimpl);
hasWaitNextEvent = (trapWaitNextEvent != trapUnimpl);
hasGestalt = (trapGestalt != trapUnimpl);
@ -631,8 +635,9 @@ int main()
}
}
#else
const Boolean hasSysEnvirons = true;
#if !TARGET_API_MAC_CARBON
const Boolean hasWaitNextEvent = true;
#endif
const Boolean hasGestalt = true;
const Boolean hasAppleEvents = true;
#endif

View File

@ -24,12 +24,10 @@ void MacSerialStream::close()
void MacSerialStream::open()
{
OSErr err;
err = OpenDriver(port ? "\p.BOut" : "\p.AOut", &outRefNum);
err = OpenDriver(port ? "\p.BIn" : "\p.AIn", &inRefNum);
OpenDriver(port ? "\p.BOut" : "\p.AOut", &outRefNum);
OpenDriver(port ? "\p.BIn" : "\p.AIn", &inRefNum);
SerSetBuf(inRefNum, inputBuffer, kInputBufferSize);
SerShk shk;
memset(&shk, 0, sizeof(shk));
shk.fCTS = true;

View File

@ -85,7 +85,6 @@ void OpenTptStream::write(const void* p, size_t n)
void OpenTptStream::tryReading()
{
OSStatus err;
OTResult result;
OTFlags flags;
do

View File

@ -16,7 +16,6 @@
# along with Retro68. If not, see <http://www.gnu.org/licenses/>.
cmake_minimum_required(VERSION 2.8)
set(CMAKE_CXX_FLAGS "--std=c++0x")
add_executable(MakeAPPL main.cc)
target_link_libraries(MakeAPPL ResourceFiles)

View File

@ -1,5 +1,3 @@
set(CMAKE_CXX_FLAGS "--std=c++11 -Wall -Werror=return-type -Wno-multichar")
find_package(Boost COMPONENTS filesystem system REQUIRED)
add_executable(MakePEF MakePEF.cc rs6000.h PEF.h)

View File

@ -16,7 +16,6 @@
# along with Retro68. If not, see <http://www.gnu.org/licenses/>.
cmake_minimum_required(VERSION 2.8)
set(CMAKE_CXX_FLAGS "--std=c++0x -Wall -Werror=return-type")
find_package(Boost COMPONENTS filesystem system REQUIRED)

View File

@ -17,15 +17,13 @@
cmake_minimum_required(VERSION 2.8)
set(CMAKE_CXX_FLAGS "--std=c++11 -Wall")
find_package(Boost COMPONENTS wave filesystem system thread regex program_options)
# Look for bison.
# We need Version 3, and Mac OS X still comes with an outdated version (2.3).
# So we just add the path where the homebrew package manager installs its
# "keg-only" version. Shouldn't hurt on Linux.
set(CMAKE_PROGRAM_PATH $CMAKE_PROGRAM_PATH "/usr/local/opt/bison/bin")
set(CMAKE_PROGRAM_PATH ${CMAKE_PROGRAM_PATH} "/usr/local/opt/bison/bin")
find_package(BISON 3.0.2)
if(Boost_FOUND AND BISON_FOUND)

View File

@ -1,4 +1,3 @@
set(CMAKE_CXX_FLAGS "--std=c++11 -Wall -Wno-multichar")
find_package(Boost COMPONENTS unit_test_framework)
add_executable(RezUnitTests UnitTests.cc)
target_link_libraries(RezUnitTests RezLib ${Boost_LIBRARIES})

View File

@ -36,8 +36,6 @@ if(APPLE)
target_link_libraries(Raytracer "-framework Carbon")
target_link_libraries(Raytracer2 "-framework Carbon")
else()
set(CMAKE_CXX_FLAGS "-std=c++11")
# save 200KB of code by removing unused stuff
set(CMAKE_EXE_LINKER_FLAGS "-Wl,-gc-sections")

View File

@ -85,12 +85,12 @@ int main(int argc, char** argv)
std::cout << "Generating numbers..." << std::flush;
const int n = 1000;
const size_t n = 1000;
std::vector<fixed> numbers(n);
std::vector<float> floats(n);
std::vector<double> doubles(n);
for(int i = 0; i < numbers.size(); i++)
for(size_t i = 0; i < numbers.size(); i++)
{
numbers[i] = fixed(std::rand(), fixed::raw());
floats[i] = float(std::rand()) / RAND_MAX;

View File

@ -76,7 +76,7 @@ public:
//if(l == 0)
// return *this;
//else
return (*this) * (T(1) / length());
return (*this) * (T(1) / l);
}
#else
vec3<T> normalize() const {

View File

@ -16,7 +16,6 @@
# along with Retro68. If not, see <http://www.gnu.org/licenses/>.
cmake_minimum_required(VERSION 2.8)
set(CMAKE_CXX_FLAGS "-std=c++11") # -fomit-frame-pointer")
add_application(EmptyTest EmptyTest.c)

View File

@ -32,7 +32,7 @@ public:
{
printf("Foo::~Foo() was called. (delaying 1 sec)\n");
long start = TickCount();
unsigned long start = TickCount();
while(TickCount() < start + 60)
;
}
@ -50,7 +50,7 @@ __attribute__((destructor))
void des()
{
printf("des() called. (delaying 1 sec)\n");
long start = TickCount();
unsigned long start = TickCount();
while(TickCount() < start + 60)
;
}