1

This is the first part of my code and I can't understand the mistake written at the end of the message. Maybe I don't know enough to understand it. I would be very grateful if someone can explain me how #pragma works and what means the mistake. Please!!

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

//estructura
#pragma pack(push, 2)
typedef struct {
char telefono[10];
char nombre[26];
char direccion[30];
int cod_cont;
}Agenda;
#pragma pack(pop)
D:/msys64/mingw64/include/vadefs.h:14:9: error: expected '=', ',', ';', 'asm' or '__attribute__' before '#pragma'
   14 | #pragma pack(push,_CRT_PACKING)
      |         ^~~~

I tried adding this parts:

#pragma pack(push, 2)
#pragma pack(pop)

but the mistake keeps popping up

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
  • 6
    The error isn't happening in your code, it's happening in the `vadefs.h` file that comes with MINGW. – Barmar Jan 06 '23 at 01:30
  • 1
    Cannot reproduce and the line looks fine. Worth looking at the file to see if there's any visible corruption above that line and then digging backward to see if one of the files included before it took an accidental edit to the face. Before I got smart enough to deny myself write permission to the include folders I'd occasionally smash a header when the debugger stepped into it. – user4581301 Jan 06 '23 at 01:40
  • What Barmar said. Notice that the error message blames `vadefs.h` line 14 and points to `#pragma pack(push,_CRT_PACKING)`, which is not your `#pragma pack(push, 2)` line. – John Kugelman Jan 06 '23 at 03:12
  • Please provide the full error message, it should also include files which have included `vadefs.h`. Your example compiles with my msys2 mingw64 just fine. – yeputons Jan 06 '23 at 03:13
  • I just solved the mistake. I wrote the name of the file in the first line but I forgot to put it as a comment. Thank y'all! – Ernestina Lede Jan 06 '23 at 14:44

0 Answers0