Skip to content

Commit

Permalink
[Ref] openmpt123: Clang 6 does support [[maybe_unused]], however Clan…
Browse files Browse the repository at this point in the history
…g in general gets angry and confused when a scope guard is used with a dummy implementation class which has no actual side effects. Mark all of them [[maybe_unused]].

git-svn-id: https://source.openmpt.org/svn/openmpt/trunk/OpenMPT@21719 56274372-70c3-4bfc-bfc3-4c3a0b034d27
  • Loading branch information
manxorist committed Sep 23, 2024
1 parent 8c05c47 commit ca0f9b1
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions openmpt123/openmpt123.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2264,26 +2264,21 @@ static mpt::uint8 main( std::vector<mpt::ustring> args ) {
const FILE_mode stdin_mode = mpt::contains( flags.filenames, MPT_NATIVE_PATH("-") ) ? FILE_mode::binary : FILE_mode::text;
const FILE_mode stdout_mode = flags.use_stdout ? FILE_mode::binary : FILE_mode::text;

const bool stdin_text = ( stdin_mode == FILE_mode::text );
const bool stdin_data = ( stdin_mode == FILE_mode::binary );
const bool stdout_text = ( stdout_mode == FILE_mode::text );
const bool stdout_data = ( stdout_mode == FILE_mode::binary );
[[maybe_unused]] const bool stdin_text = ( stdin_mode == FILE_mode::text );
[[maybe_unused]] const bool stdin_data = ( stdin_mode == FILE_mode::binary );
[[maybe_unused]] const bool stdout_text = ( stdout_mode == FILE_mode::text );
[[maybe_unused]] const bool stdout_data = ( stdout_mode == FILE_mode::binary );

// set stdin/stdout to binary for data input/output
std::optional<FILE_mode_guard> stdin_guard{ stdin_data ? std::make_optional<FILE_mode_guard>( stdin, FILE_mode::binary ) : std::nullopt };
std::optional<FILE_mode_guard> stdout_guard{ stdout_data ? std::make_optional<FILE_mode_guard>( stdout, FILE_mode::binary ) : std::nullopt };
[[maybe_unused]] std::optional<FILE_mode_guard> stdin_guard{ stdin_data ? std::make_optional<FILE_mode_guard>( stdin, FILE_mode::binary ) : std::nullopt };
[[maybe_unused]] std::optional<FILE_mode_guard> stdout_guard{ stdout_data ? std::make_optional<FILE_mode_guard>( stdout, FILE_mode::binary ) : std::nullopt };

// setup terminal
std::optional<terminal_ui_guard> input_guard{ stdin_text && ( flags.mode == Mode::UI ) ? std::make_optional<terminal_ui_guard>() : std::nullopt };
[[maybe_unused]] std::optional<terminal_ui_guard> input_guard{ stdin_text && ( flags.mode == Mode::UI ) ? std::make_optional<terminal_ui_guard>() : std::nullopt };

// choose text output between quiet/stdout/stderr
textout & log = flags.quiet ? static_cast<textout&>( dummy_log ) : stdout_text ? static_cast<textout&>( std_out ) : static_cast<textout&>( std_err );

MPT_UNUSED( stdin_text );
MPT_UNUSED( stdin_data );
MPT_UNUSED( stdout_text );
MPT_UNUSED( stdout_data );

show_banner( log, flags.banner );

if ( !flags.warnings.empty() ) {
Expand Down

0 comments on commit ca0f9b1

Please sign in to comment.