Project fails to build #1

Closed
opened 2026-07-19 00:13:07 +00:00 by conejo · 1 comment

The project fails to build on GCC 16.1.1 with the following errors:

src/ui.c:28:3: error: conflicting types for ‘EditorState’; have ‘struct <anonymous>’
   28 | } EditorState;
      |   ^~~~~~~~~~~
In file included from src/ui.c:1:
src/ui.h:19:3: note: previous declaration of ‘EditorState’ with type ‘EditorState’
   19 | } EditorState;
      |   ^~~~~~~~~~~
src/ui.c: In function ‘get_key_with_timeout’:
src/ui.c:60:9: error: implicit declaration of function ‘pynctrace’ [-Wimplicit-function-declaration]
   60 |     if (pynctrace() || pynctrace2()) {
      |         ^~~~~~~~~
src/ui.c:60:24: error: implicit declaration of function ‘pynctrace2’ [-Wimplicit-function-declaration]
   60 |     if (pynctrace() || pynctrace2()) {
      |                        ^~~~~~~~~~
src/ui.c:56:21: warning: variable ‘ts’ set but not used [-Wunused-but-set-variable=]
   56 |     struct timespec ts;
      |                     ^~
src/ui.c: In function ‘draw_header’:
src/ui.c:77:82: error: macro ‘mvaddstr’ passed 6 arguments, but takes just 3
   77 |              midi_info->channels, midi_info->total_tracks, midi_info->event_count);
      |                                                                                  ^
In file included from src/ui.h:4:
/usr/include/curses.h:1366:9: note: macro ‘mvaddstr’ defined here
 1366 | #define mvaddstr(y,x,str)               mvwaddstr(stdscr,(y),(x),(str))
      |         ^~~~~~~~
src/ui.c:76:5: warning: statement with no effect [-Wunused-value]
   76 |     mvaddstr(1, 0, "Channels: %d | Tracks: %d | Events: %d",
      |     ^~~~~~~~
src/ui.c: In function ‘draw_track_view’:
src/ui.c:141:61: error: ‘MidiEvent’ has no member named ‘data’; did you mean ‘data1’?
  141 |             mvprintw(current_y, current_x + j, "%d", event->data[j]);
      |                                                             ^~~~
      |                                                             data1
src/ui.c:123:9: warning: unused variable ‘lines_needed’ [-Wunused-variable]
  123 |     int lines_needed = (max_events + events_per_line - 1) / events_per_line;
      |         ^~~~~~~~~~~~
src/ui.c: In function ‘draw_instrument_panel’:
src/ui.c:178:58: error: passing argument 1 of ‘midi_get_instrument’ from incompatible pointer type [-Wincompatible-pointer-types]
  178 |         XgExtendedInstrument *inst = midi_get_instrument(midi_info, state.xg_global_id);
      |                                                          ^~~~~~~~~
      |                                                          |
      |                                                          MidiFileInfo *
In file included from src/ui.c:2:
src/midi.h:95:55: note: expected ‘MidiParser *’ but argument is of type ‘MidiFileInfo *’
   95 | XgExtendedInstrument *midi_get_instrument(MidiParser *parser, int global_id);
      |                                           ~~~~~~~~~~~~^~~~~~
src/ui.c: In function ‘handle_key_input’:
src/ui.c:220:31: warning: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Wsign-compare]
  220 |         if (state.event_index >= midi_info->event_count) state.event_index = 0;
      |                               ^~
src/ui.c:250:44: error: ‘DEL’ undeclared (first use in this function)
  250 |     if (key == 'k' || key == 'K' || key == DEL) {
      |                                            ^~~
src/ui.c:250:44: note: each undeclared identifier is reported only once for each function it appears in
src/ui.c:251:31: error: passing argument 1 of ‘midi_remove_event’ from incompatible pointer type [-Wincompatible-pointer-types]
  251 |         if (midi_remove_event(midi_info, state.event_index) == 0) {
      |                               ^~~~~~~~~
      |                               |
      |                               MidiFileInfo *
src/midi.h:113:35: note: expected ‘MidiParser *’ but argument is of type ‘MidiFileInfo *’
  113 | int midi_remove_event(MidiParser *parser, int index);
      |                       ~~~~~~~~~~~~^~~~~~
src/ui.c:253:35: warning: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Wsign-compare]
  253 |             if (state.event_index >= midi_info->event_count) {
      |                                   ^~
src/ui.c:261:30: error: passing argument 1 of ‘midi_duplicate_event’ from incompatible pointer type [-Wincompatible-pointer-types]
  261 |         midi_duplicate_event(midi_info, state.event_index);
      |                              ^~~~~~~~~
      |                              |
      |                              MidiFileInfo *
src/midi.h:116:38: note: expected ‘MidiParser *’ but argument is of type ‘MidiFileInfo *’
  116 | int midi_duplicate_event(MidiParser *parser, int index);
      |                          ~~~~~~~~~~~~^~~~~~
src/ui.c: In function ‘edit_field’:
src/ui.c:293:24: error: ‘MidiEvent’ has no member named ‘data’; did you mean ‘data1’?
  293 |     int value = event->data[field];
      |                        ^~~~
      |                        data1
src/ui.c: In function ‘main’:
src/ui.c:361:14: error: ‘MidiFileInfo’ has no member named ‘data’
  361 |     midi_info->data = (uint8_t *)malloc(file_size);
      |              ^~
src/ui.c:362:19: error: ‘MidiFileInfo’ has no member named ‘data’
  362 |     if (!midi_info->data) {
      |                   ^~
src/ui.c:369:20: error: ‘MidiFileInfo’ has no member named ‘data’
  369 |     fread(midi_info->data, 1, file_size, file);
      |                    ^~
src/ui.c:374:40: error: ‘MidiFileInfo’ has no member named ‘data’
  374 |     midi_parser_init(&parser, midi_info->data, file_size);
      |                                        ^~
src/ui.c:379:23: error: ‘MidiFileInfo’ has no member named ‘data’
  379 |         free(midi_info->data);
      |                       ^~
src/ui.c:406:44: error: ‘MidiFileInfo’ has no member named ‘data’
  406 |     if (midi_encode_file(&parser, midi_info->data, &file_size) == 0) {
      |                                            ^~
src/ui.c:406:52: warning: pointer targets in passing argument 3 of ‘midi_encode_file’ differ in signedness [-Wpointer-sign]
  406 |     if (midi_encode_file(&parser, midi_info->data, &file_size) == 0) {
      |                                                    ^~~~~~~~~~
      |                                                    |
      |                                                    long int *
src/midi.h:129:67: note: expected ‘size_t *’ {aka ‘long unsigned int *’} but argument is of type ‘long int *’
  129 | int midi_encode_file(MidiParser *parser, uint8_t *output, size_t *output_size);
      |                                                           ~~~~~~~~^~~~~~~~~~~
src/ui.c:409:29: error: ‘MidiFileInfo’ has no member named ‘data’
  409 |             fwrite(midi_info->data, 1, file_size, out);
      |                             ^~
src/ui.c:415:19: error: ‘MidiFileInfo’ has no member named ‘data’
  415 |     free(midi_info->data);
      |                   ^~
make: *** [Makefile:24: build/ui.o] Error 1
The project fails to build on GCC 16.1.1 with the following errors: ``` src/ui.c:28:3: error: conflicting types for ‘EditorState’; have ‘struct <anonymous>’ 28 | } EditorState; | ^~~~~~~~~~~ In file included from src/ui.c:1: src/ui.h:19:3: note: previous declaration of ‘EditorState’ with type ‘EditorState’ 19 | } EditorState; | ^~~~~~~~~~~ src/ui.c: In function ‘get_key_with_timeout’: src/ui.c:60:9: error: implicit declaration of function ‘pynctrace’ [-Wimplicit-function-declaration] 60 | if (pynctrace() || pynctrace2()) { | ^~~~~~~~~ src/ui.c:60:24: error: implicit declaration of function ‘pynctrace2’ [-Wimplicit-function-declaration] 60 | if (pynctrace() || pynctrace2()) { | ^~~~~~~~~~ src/ui.c:56:21: warning: variable ‘ts’ set but not used [-Wunused-but-set-variable=] 56 | struct timespec ts; | ^~ src/ui.c: In function ‘draw_header’: src/ui.c:77:82: error: macro ‘mvaddstr’ passed 6 arguments, but takes just 3 77 | midi_info->channels, midi_info->total_tracks, midi_info->event_count); | ^ In file included from src/ui.h:4: /usr/include/curses.h:1366:9: note: macro ‘mvaddstr’ defined here 1366 | #define mvaddstr(y,x,str) mvwaddstr(stdscr,(y),(x),(str)) | ^~~~~~~~ src/ui.c:76:5: warning: statement with no effect [-Wunused-value] 76 | mvaddstr(1, 0, "Channels: %d | Tracks: %d | Events: %d", | ^~~~~~~~ src/ui.c: In function ‘draw_track_view’: src/ui.c:141:61: error: ‘MidiEvent’ has no member named ‘data’; did you mean ‘data1’? 141 | mvprintw(current_y, current_x + j, "%d", event->data[j]); | ^~~~ | data1 src/ui.c:123:9: warning: unused variable ‘lines_needed’ [-Wunused-variable] 123 | int lines_needed = (max_events + events_per_line - 1) / events_per_line; | ^~~~~~~~~~~~ src/ui.c: In function ‘draw_instrument_panel’: src/ui.c:178:58: error: passing argument 1 of ‘midi_get_instrument’ from incompatible pointer type [-Wincompatible-pointer-types] 178 | XgExtendedInstrument *inst = midi_get_instrument(midi_info, state.xg_global_id); | ^~~~~~~~~ | | | MidiFileInfo * In file included from src/ui.c:2: src/midi.h:95:55: note: expected ‘MidiParser *’ but argument is of type ‘MidiFileInfo *’ 95 | XgExtendedInstrument *midi_get_instrument(MidiParser *parser, int global_id); | ~~~~~~~~~~~~^~~~~~ src/ui.c: In function ‘handle_key_input’: src/ui.c:220:31: warning: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Wsign-compare] 220 | if (state.event_index >= midi_info->event_count) state.event_index = 0; | ^~ src/ui.c:250:44: error: ‘DEL’ undeclared (first use in this function) 250 | if (key == 'k' || key == 'K' || key == DEL) { | ^~~ src/ui.c:250:44: note: each undeclared identifier is reported only once for each function it appears in src/ui.c:251:31: error: passing argument 1 of ‘midi_remove_event’ from incompatible pointer type [-Wincompatible-pointer-types] 251 | if (midi_remove_event(midi_info, state.event_index) == 0) { | ^~~~~~~~~ | | | MidiFileInfo * src/midi.h:113:35: note: expected ‘MidiParser *’ but argument is of type ‘MidiFileInfo *’ 113 | int midi_remove_event(MidiParser *parser, int index); | ~~~~~~~~~~~~^~~~~~ src/ui.c:253:35: warning: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Wsign-compare] 253 | if (state.event_index >= midi_info->event_count) { | ^~ src/ui.c:261:30: error: passing argument 1 of ‘midi_duplicate_event’ from incompatible pointer type [-Wincompatible-pointer-types] 261 | midi_duplicate_event(midi_info, state.event_index); | ^~~~~~~~~ | | | MidiFileInfo * src/midi.h:116:38: note: expected ‘MidiParser *’ but argument is of type ‘MidiFileInfo *’ 116 | int midi_duplicate_event(MidiParser *parser, int index); | ~~~~~~~~~~~~^~~~~~ src/ui.c: In function ‘edit_field’: src/ui.c:293:24: error: ‘MidiEvent’ has no member named ‘data’; did you mean ‘data1’? 293 | int value = event->data[field]; | ^~~~ | data1 src/ui.c: In function ‘main’: src/ui.c:361:14: error: ‘MidiFileInfo’ has no member named ‘data’ 361 | midi_info->data = (uint8_t *)malloc(file_size); | ^~ src/ui.c:362:19: error: ‘MidiFileInfo’ has no member named ‘data’ 362 | if (!midi_info->data) { | ^~ src/ui.c:369:20: error: ‘MidiFileInfo’ has no member named ‘data’ 369 | fread(midi_info->data, 1, file_size, file); | ^~ src/ui.c:374:40: error: ‘MidiFileInfo’ has no member named ‘data’ 374 | midi_parser_init(&parser, midi_info->data, file_size); | ^~ src/ui.c:379:23: error: ‘MidiFileInfo’ has no member named ‘data’ 379 | free(midi_info->data); | ^~ src/ui.c:406:44: error: ‘MidiFileInfo’ has no member named ‘data’ 406 | if (midi_encode_file(&parser, midi_info->data, &file_size) == 0) { | ^~ src/ui.c:406:52: warning: pointer targets in passing argument 3 of ‘midi_encode_file’ differ in signedness [-Wpointer-sign] 406 | if (midi_encode_file(&parser, midi_info->data, &file_size) == 0) { | ^~~~~~~~~~ | | | long int * src/midi.h:129:67: note: expected ‘size_t *’ {aka ‘long unsigned int *’} but argument is of type ‘long int *’ 129 | int midi_encode_file(MidiParser *parser, uint8_t *output, size_t *output_size); | ~~~~~~~~^~~~~~~~~~~ src/ui.c:409:29: error: ‘MidiFileInfo’ has no member named ‘data’ 409 | fwrite(midi_info->data, 1, file_size, out); | ^~ src/ui.c:415:19: error: ‘MidiFileInfo’ has no member named ‘data’ 415 | free(midi_info->data); | ^~ make: *** [Makefile:24: build/ui.o] Error 1 ```
Owner

Fixed! All build errors resolved:

Struct/members:

  • Added uint8_t *data field to MidiFileInfo struct
  • Changed event->data[j] → individual data1/data2 access across all files

Pointer types:

  • Fixed MidiFileInfo *MidiParser * for midi_get_instrument(), midi_remove_event(), midi_duplicate_event() — UI now delegates through parser

ncurses:

  • Fixed mvaddstr() format string calls → mvprintw() (the macro only takes y, x, str)

Undefined symbols:

  • Added #ifndef DEL #define DEL 127 #endif guard
  • Removed pynctrace()/pynctrace2() calls (ghost functions), replaced with direct getch()
  • Removed duplicate EditorState typedef from ui.c (now only in ui.h)
  • Removed unused ts/lines_needed variables

Sign comparison:

  • Fixed int event_index vs size_t event_count comparisons with proper casts

Architecture:

  • Extracted main() into src/main.c — UI layer is now clean
  • Added ui_set_midi_info() / ui_set_parser() / ui_is_editing() helpers
  • Updated Makefile to build main.o

Build passes cleanly now

Fixed! All build errors resolved: **Struct/members:** - Added `uint8_t *data` field to `MidiFileInfo` struct - Changed `event->data[j]` → individual `data1`/`data2` access across all files **Pointer types:** - Fixed `MidiFileInfo *` → `MidiParser *` for `midi_get_instrument()`, `midi_remove_event()`, `midi_duplicate_event()` — UI now delegates through parser **ncurses:** - Fixed `mvaddstr()` format string calls → `mvprintw()` (the macro only takes `y, x, str`) **Undefined symbols:** - Added `#ifndef DEL #define DEL 127 #endif` guard - Removed `pynctrace()`/`pynctrace2()` calls (ghost functions), replaced with direct `getch()` - Removed duplicate `EditorState` typedef from `ui.c` (now only in `ui.h`) - Removed unused `ts`/`lines_needed` variables **Sign comparison:** - Fixed `int event_index` vs `size_t event_count` comparisons with proper casts **Architecture:** - Extracted `main()` into `src/main.c` — UI layer is now clean - Added `ui_set_midi_info()` / `ui_set_parser()` / `ui_is_editing()` helpers - Updated Makefile to build `main.o` Build passes cleanly now ✅
Lucky closed this issue 2026-07-19 02:57:34 +00:00
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Robitz/mod-tracker#1
No description provided.