Skip to content

Conversation

@hasseily
Copy link

Here are a number of fixes that will allow sa2 to compile cleanly in Visual Studio.
Most of the changes are GCC-specific fixes.
The biggest change is the addition of getopt.c and getopt.h specifically for Windows builds.

There's also a modification to StdAfx.h which lets CMakeLists disable the speech api when using sa2 on Windows.

@hasseily
Copy link
Author

The fixes now also allow using Xcode

-Wno-multichar
if (MSVC)
target_compile_options(appleii PUBLIC
/wd4566 # disable multi-character constant warning
Copy link
Owner

Choose a reason for hiding this comment

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

ideally we should fix this code in the upstream repo. can you propose a MR there.

Copy link
Author

Choose a reason for hiding this comment

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

Let me see where it pukes and propose a PR

Copy link
Author

Choose a reason for hiding this comment

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

Well they use /utf-8 in the upstream repo so here for MSVC I can use:
add_compile_options(/utf-8)
instead of /wd4566, which tracks closer to upstream. But your -Wno-multichar is also /wd4566.
Thoughts?

#include <string.h>
#include <stdio.h>

// For Windows MSVC only
Copy link
Owner

Choose a reason for hiding this comment

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

where does this code come from?

Copy link
Author

Choose a reason for hiding this comment

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

ChatGPT. There are tons of versions of this code online. I would credit someone but the amount of copy-paste in there is quite significant.

Copy link
Owner

Choose a reason for hiding this comment

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

uhm... originally I was using boost which is well tested and portable. nobody likes it, so now we replace it with some random code which has no guarantee to behave the same as the target getopt. I see it as a regression,not a way forward.

Copy link
Author

Choose a reason for hiding this comment

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

We are committing to a multiplatform codebase. We ahould be using the easiest and most reliable code to do that. Because MSVC doesn't have getopt I hacked together something to make it compile. But if instead we use boost I have no problem, the more reliable and the fewer platform-specific splits the better.
Did people say no to boost? It's big and cumbersome, but multiplatform is big and cumbersome. I really really think we should have ONE multiplatform codebase, with ONE front end that works 100% across all platforms, where any dev on any platform can use the canonical IDE to work on the codebase.

Copy link
Author

Choose a reason for hiding this comment

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

I did try a switch (back?) from argparser.cpp to boost::program_options, removing getopt althogether and it certainly is a better multiplatform solution. Let me know if you want me to include it in the PR while we're at it.

Copy link
Owner

Choose a reason for hiding this comment

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

I have moved to getopt recently because the libretro build cannot use boost. let me fix all the rest and then we come back to this.

Copy link
Author

Choose a reason for hiding this comment

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

Quick comment: you still use boost::property_tree in common2 so that would also have to go if we're getting off boost 100%

adjustMouseText(text, length, utf8);
debuggerTextColored(iColor, utf8);
std::string utf8(2 * length + 1, '\0'); // worst case is 2-bytes utf8 encoding
adjustMouseText(text, length, utf8.data());
Copy link
Owner

Choose a reason for hiding this comment

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

what is the issue here?

Copy link
Author

Choose a reason for hiding this comment

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

MSVC wants the expression to have a constant value.
So to do dynamic memory allocation I just use an std::string.

audetto added a commit that referenced this pull request Sep 27, 2025
#306

Signed-off-by: Andrea Odetti <mariofutire@gmail.com>
audetto added a commit that referenced this pull request Sep 27, 2025
#306

Signed-off-by: Andrea Odetti <mariofutire@gmail.com>
audetto added a commit that referenced this pull request Oct 4, 2025
#306

Signed-off-by: Andrea Odetti <mariofutire@gmail.com>
@audetto
Copy link
Owner

audetto commented Oct 5, 2025

I've committed all non controversial code changes.
If you re-synch this branch I will have a look at the VS specific makefile changes.

@hasseily
Copy link
Author

hasseily commented Oct 5, 2025

Done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants