Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set C++ to 17, and a few CMake fixes for Linux #20

Merged
merged 2 commits into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,22 @@ PROJECT(Descent3)
IF (UNIX)
SET (D3_GAMEDIR "~/Descent3/")

SET(CMAKE_CXX_STANDARD 17)
SET(CMAKE_CXX_STANDARD_REQUIRED ON)
SET(CMAKE_CXX_EXTENSIONS OFF)
SET(CMAKE_POSITION_INDEPENDENT_CODE ON)

IF (APPLE)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I doubt that in Apple there may 64bit code generated. Also, -m32 should be added via compiler toolchain, not directly in CMake project file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, -m32 did not quite work, removed entirely.

SET(EXTRA_CXX_FLAGS "-Wno-address-of-temporary")
ELSE()
SET(EXTRA_CXX_FLAGS "-fpermissive")
ENDIF()

SET(CMAKE_CXX_COMPILER "g++")
SET(CMAKE_CXX_FLAGS "-O0 -g -Wno-write-strings -Wno-multichar -Wno-address-of-temporary")
SET(CMAKE_C_FLAGS "-O0 -g")
SET(CMAKE_CXX_FLAGS "-O0 -g -Wno-write-strings -Wno-multichar ${BITS} ${EXTRA_CXX_FLAGS}")
SET(CMAKE_C_FLAGS "-O0 -g ${BITS}")
SET(CMAKE_C_COMPILER "gcc")
IF (NOT APPLE)
LIST(APPEND CMAKE_CXX_FLAGS "-m32")
LIST(APPEND CMAKE_C_FLAGS "-m32")
ENDIF()

FIND_PACKAGE( SDL REQUIRED )
IF (APPLE)
# Provide FIND_PACKAGE( SDL_image ) below with an include dir and library that work with brew-installed sdl2_image
Expand Down
2 changes: 2 additions & 0 deletions Descent3/cinematics.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
#include "renderer.h"
#include "bitmap.h"

#include <cstdint>

// Movie Cinematic
typedef struct tCinematic {
intptr_t mvehandle;
Expand Down
2 changes: 1 addition & 1 deletion lib/findintersection.h
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ extern bool FVI_always_check_ceiling;
inline bool FastVectorBBox(const float *min, const float *max, const float *origin, const float *dir) {
bool f_inside = true;
char quad[3];
register int i;
int i;
float max_t[3];
float can_plane[3];
int which_plane;
Expand Down
2 changes: 2 additions & 0 deletions lib/movie.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

#include "renderer.h"

#include <cstdint>

#define MVELIB_NOERROR 0
#define MVELIB_FILE_ERROR -1
#define MVELIB_NOTINIT_ERROR -2
Expand Down
2 changes: 1 addition & 1 deletion md5/md5.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ void MD5::MD5Final(unsigned char digest[16]) {
* the data and converts bytes into longwords for this routine.
*/
void MD5::MD5Transform(uint32_t buf[4], uint32_t const in[16]) {
register uint32_t a, b, c, d;
uint32_t a, b, c, d;

a = buf[0];
b = buf[1];
Expand Down
16 changes: 8 additions & 8 deletions misc/psglob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@

// Returns 1 if string contains globbing characters in it
int PSGlobHasPattern(char *string) {
register char *p = string;
register char c;
char *p = string;
char c;
int open = 0;

while ((c = *p++) != '\0') {
Expand Down Expand Up @@ -70,8 +70,8 @@ int PSGlobHasPattern(char *string) {
// 8) If dot_special is not zero, '*' and '?' do not match '.' at the beginning of text
// 9) If case_sensitive is 0, than case does not matter for the non-pattern characters
int PSGlobMatch(char *pattern, char *text, int case_sensitive, int dot_special) {
register char *p = pattern, *t = text;
register char c;
char *p = pattern, *t = text;
char c;

while ((c = *p++) != '\0') {
switch (c) {
Expand All @@ -90,7 +90,7 @@ int PSGlobMatch(char *pattern, char *text, int case_sensitive, int dot_special)
return 0;
return PSGlobMatchAfterStar(p, case_sensitive, t);
case '[': {
register char c1 = *t++;
char c1 = *t++;
int invert;

if (!c1)
Expand All @@ -102,7 +102,7 @@ int PSGlobMatch(char *pattern, char *text, int case_sensitive, int dot_special)
c = *p++;

while (1) {
register char cstart = c, cend = c;
char cstart = c, cend = c;
if (c == '\\') {
cstart = *p++;
cend = cstart;
Expand Down Expand Up @@ -162,8 +162,8 @@ int PSGlobMatch(char *pattern, char *text, int case_sensitive, int dot_special)

// Like PSGlobMatch, but match pattern against any final segment of text
int PSGlobMatchAfterStar(char *pattern, int case_sensitive, char *text) {
register char *p = pattern, *t = text;
register char c, c1;
char *p = pattern, *t = text;
char c, c1;

while ((c = *p++) == '?' || c == '*') {
if (c == '?' && *t++ == '\0')
Expand Down
2 changes: 1 addition & 1 deletion scripts/osiris_import.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#ifdef __LINUX__
#ifndef MACOSX
typedef unsigned int size_t;
// typedef unsigned int size_t;
#endif
#include <stdarg.h>
void _splitpath(const char *path, char *drive, char *dir, char *fname, char *ext);
Expand Down