Skip to content

Conversation

myQwil
Copy link
Contributor

@myQwil myQwil commented Mar 5, 2025

avoid including headers where they aren't being directly used

in floating point arithmetic, use int multiplication over int division, or be explicit about using division.

use C++-standardized, namespace-aware headers instead of the older C-style headers.

@@ -4,7 +4,7 @@
#ifndef AY_CPU_H
#define AY_CPU_H

#include "blargg_endian.h"
Copy link
Contributor

Choose a reason for hiding this comment

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

Patch is big. But at least this particular bit is wrong: This header references endian macros, but it now doen't include blargg_endian.h, and in Ay_Cpu.c where it is included blargg_endian.h is included after Ay_Cpu.h

There may be other breakages, too...

Copy link
Contributor Author

@myQwil myQwil Mar 5, 2025

Choose a reason for hiding this comment

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

I'm not sure I follow. The header doesn't use blargg_endian.h but the source file does. Wouldn't the build have failed if this weren't the case?

What happens as a result of blargg_endian.h being included after Ay_Cpu.h?

Copy link
Contributor

Choose a reason for hiding this comment

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

Build with -Wundef to see: In short, big endian define will be missing and builds on big endian arches will be wrong

Copy link
Contributor Author

@myQwil myQwil Mar 5, 2025

Choose a reason for hiding this comment

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

When you say big endian define, are you referring to BLARGG_BIG_ENDIAN?

If so, that's not defined in blargg_endian.h, that gets defined by the build system.

It looks like a lot of these undef warnings could be remedied by simply changing #if to #ifdef/#ifndef

Copy link
Contributor

Choose a reason for hiding this comment

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

When you say big endian define, are you referring to BLARGG_BIG_ENDIAN?

Yes

If so, that's not defined in blargg_endian.h, that gets defined by the build system.

Well, you're actually correct (and I was the one who did it that way.. face palm..)

It looks like a lot of these undef warnings could be remedied by simply changing #if to #ifdef/#ifndef

Be really careful there.

And I hope that you don't include such a changeset in here: One patch, doing only one thing at a time should be the norm.

@@ -121,8 +121,6 @@ class Blip_Buffer {
friend class Blip_Reader;
};

#include "blargg_config.h"
Copy link
Contributor

Choose a reason for hiding this comment

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

Why remove this?

It can be useful when building through standalone makefiles, for e.g.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, it's been put back in.

@@ -5,8 +5,7 @@
#ifndef GB_CPU_H
#define GB_CPU_H

#include "blargg_common.h"
#include "blargg_endian.h"
Copy link
Contributor

Choose a reason for hiding this comment

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

Same issue noted with Ay_Cpu.h changes above

@@ -15,8 +13,6 @@ details. You should have received a copy of the GNU Lesser General Public
License along with this module; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */

#include "blargg_source.h"
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this really not needed here? (Haven't read carefully this part)

Copy link
Contributor Author

@myQwil myQwil Mar 5, 2025

Choose a reason for hiding this comment

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

Maybe it was left over from a time when it was needed.

@@ -4,8 +4,8 @@
#ifndef GB_OSCS_H
#define GB_OSCS_H

#include "blargg_common.h"
Copy link
Contributor

Choose a reason for hiding this comment

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

(Same as above)

@@ -4,7 +4,7 @@
#ifndef KSS_CPU_H
#define KSS_CPU_H

#include "blargg_endian.h"
Copy link
Contributor

Choose a reason for hiding this comment

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

same issue noted with Ay_Cpu.h changes noted above

@@ -5,9 +5,7 @@
#define SNES_SPC_H

#include "Spc_Dsp.h"
#include "blargg_endian.h"
Copy link
Contributor

Choose a reason for hiding this comment

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

same issue noted with Ay_Cpu.h changes noted above

@sezero
Copy link
Contributor

sezero commented Mar 5, 2025

In general, I personally don't like this patch very much, at least as it is. It doesn't fix real issues, but seem to satisfy clang witch hunt only. An includes clean-up like <xxx.h> to <cxxx> alone might be considered OK, but even that isn' really necessary.

@Wohlstand
Copy link
Collaborator

Sorry for not paying attention on this, but, any changes should be done VERY carefully. Sezer pointed the rest of problems already. I'll try to consume this by myself, taking the best of these changes only and ensuring nothing will hurt.

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.

3 participants