Skip to content

Declare Studio's net field under the condition it is used - #2982

Open
annejan wants to merge 1 commit into
nesbox:mainfrom
annejan:fix-studio-net-guard
Open

Declare Studio's net field under the condition it is used#2982
annejan wants to merge 1 commit into
nesbox:mainfrom
annejan:fix-studio-net-guard

Conversation

@annejan

@annejan annejan commented Aug 21, 2026

Copy link
Copy Markdown

studio->net is read wherever either BUILD_EDITORS or BUILD_SURF is set:

#if defined(BUILD_EDITORS) || defined(BUILD_SURF)
    initConsole(studio->console, studio, studio->fs, studio->net, studio->config, args);
#endif

but the field itself is declared only under BUILD_SURF, so compiling the studio with BUILD_EDITORS and without BUILD_SURF fails:

src/studio/studio.c:2966:60: error: 'Studio' has no member named 'net'

Worth being upfront: CMakeLists.txt:59 sets BUILD_SURF ON whenever BUILD_EDITORS is set, so no in-tree build produces that combination. This only bites builds that compile these sources directly with their own definitions — I ran into it porting TIC-80 to the ESP32-P4, wanting the editors without the network layer.

The change

The declaration now carries the same condition as its use, matching the Console* field immediately above it. Three added lines, no deletions.

No configuration that builds today is affected: with BUILD_SURF defined the preprocessed result is identical. Verified by building the SDL target.

Note this makes that configuration compile; it does not make it fully work. console.c calls tic_net_get(console->net, ...) outside any BUILD_SURF guard, so with no network layer that would be a null tic_net. net.c's fallback implementation handles a null and fails the request cleanly, but the naett path would not. Fixing that properly means deciding whether console's version check and download paths should be BUILD_SURF-only, which felt like your call rather than mine — happy to follow up if you want it.

studio->net is read where either BUILD_EDITORS or BUILD_SURF is set:

    initConsole(studio->console, studio, studio->fs, studio->net, ...)

but the field is declared only under BUILD_SURF, so compiling the studio
with BUILD_EDITORS and without BUILD_SURF fails:

    error: 'Studio' has no member named 'net'

CMakeLists.txt turns BUILD_SURF on whenever BUILD_EDITORS is set, so the
in-tree builds never produce that combination; it is out-of-tree builds
compiling these sources directly that run into it.

The declaration now carries the same condition as the use, matching the
Console field just above it. No configuration that builds today changes:
with BUILD_SURF defined the preprocessed result is identical.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@joshgoebel

Copy link
Copy Markdown
Collaborator

Note this makes that configuration compile; it does not make it fully work.

Obviously up to nesbox, but I'm not sure we should ship one without the other. Right now we have a hard error (I presume) telling someone "this combo doesn't work"... If we take that away we'd need to figure out where to document this where people would be sure to read it.

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