VS2010 buildfixes.

The main issue was mostly that we have to build C files as C++ in some
cases, and extern "C" wasn't being used everywhere, so linker errors
popped up. The rest is the usual tedious VS2010 stuff like casting void*
to other stuff, so this commit as a whole is pretty boring!
This commit is contained in:
Ethan Lee 2023-11-27 12:09:42 -05:00
parent 4725bc4d5e
commit 8426e0930d
6 changed files with 30 additions and 15 deletions

View File

@ -1,11 +1,10 @@
#include "CWrappers.h"
#include <SDL.h>
#include "Localization.h"
#include "UtilityClass.h"
extern "C"
{
char* HELP_number_words(int _t)
{
/* C wrapper for UtilityClass::number_words.
@ -24,5 +23,3 @@ uint32_t LOC_toupper_ch(uint32_t ch)
{
return loc::toupper_ch(ch);
}
} /* extern "C" */

View File

@ -1,7 +1,17 @@
#ifndef CWRAPPERS_H
#define CWRAPPERS_H
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
char* HELP_number_words(int _t);
uint32_t LOC_toupper_ch(uint32_t ch);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* CWRAPPERS_H */

View File

@ -108,5 +108,5 @@ const char* textbook_store(Textbook* textbook, const char* text)
return "";
}
return textbook_store_raw(textbook, text, SDL_strlen(text)+1);
return (const char*) textbook_store_raw(textbook, text, SDL_strlen(text)+1);
}

View File

@ -39,7 +39,7 @@ int vformat_button(ActionSet actionset, int action)
static void vformat_unbutton(ActionSet* actionset, Action* action, const int vararg_value)
{
// Unpack the ActionSet and Action from a packed vararg value.
*actionset = vararg_value >> 16;
*actionset = (ActionSet) (vararg_value >> 16);
action->intval = vararg_value & 0xFFFF;
}
@ -207,7 +207,11 @@ void vformat_cb_valist(
* The arguments index string is comma-separated,
* each argument is name:type. */
va_list args_copy;
#ifndef va_copy /* Older VS releases don't have this yet, just copy the old way */
args_copy = args;
#else
va_copy(args_copy, args);
#endif
const char* args_index_cursor = args_index;
@ -385,11 +389,10 @@ size_t vformat_buf_valist(
{
/* Variant of vformat_buf which takes a va_list instead of `...` */
buffer_info buf = {
.total_needed = 1,
.buffer_cursor = buffer,
.buffer_left = buffer_len
};
buffer_info buf;
buf.total_needed = 1;
buf.buffer_cursor = buffer;
buf.buffer_left = buffer_len;
if (buf.buffer_left != 0)
{
@ -438,7 +441,7 @@ char* vformat_alloc_valist(
/* Variant of vformat_alloc which takes a va_list instead of `...` */
size_t needed = vformat_buf_valist(NULL, 0, format_string, args_index, args);
char* buffer = SDL_malloc(needed);
char* buffer = (char*) SDL_malloc(needed);
if (buffer == NULL)
{
return NULL;

View File

@ -1,4 +1,5 @@
#include <SDL_stdinc.h>
#include "Vlogging.h"
#include <stdarg.h>
#include <stdio.h>
@ -258,6 +259,10 @@ static void check_color_support(void)
return;
}
/* Older VS releases don't have this defined yet */
#ifndef ENABLE_VIRTUAL_TERMINAL_PROCESSING
#define ENABLE_VIRTUAL_TERMINAL_PROCESSING 0x0004
#endif
const BOOL success = SetConsoleMode(
hStdout, ENABLE_PROCESSED_OUTPUT | ENABLE_VIRTUAL_TERMINAL_PROCESSING
);

View File

@ -1,4 +1,4 @@
#include <stdint.h>
#include "Xoshiro.h"
#include "Vlogging.h"