Re: [m-users.] C compiler error
Volker Wysk <[email protected]>
| Newsgroups | gmane.comp.lang.mercury.general |
|---|---|
| Message-ID | <[email protected]> |
Am Dienstag, dem 28.02.2023 um 04:13 +1100 schrieb Zoltan Somogyi: > > On Mon, 27 Feb 2023 18:05:09 +0100, Volker Wysk <[email protected]> wrote: > > I've taken a look at the mq.c file. There, mq_module0, mq_module1 and so on > > are automatically generated C functions. And their storage class is invalid. > > So this would be a Mercury compiler bug. > > Only if you consider the Mercury compiler's inability to automatically fix > a bug in user-provided C code to be a bug in the Mercury compiler :-( > > > Am Montag, dem 27.02.2023 um 15:49 +0100 schrieb Volker Wysk: > > > Hi. > > > > > > I have a Mercury module with a lot of foreign C code, and I get many > > > compiler errors like this: > > > > > > Making Mercury/os/mq.o > > > Mercury/cs/mq.c: In function ‘null_to_empty’: > > > Mercury/cs/mq.c:644:1: error: invalid storage class for function > > > ‘mq_module0’ > > > Mercury/cs/mq.c:644:1: error: invalid storage class for function > > > ‘mq_module0’ > > > Mercury/cs/mq.c:764:1: error: invalid storage class for function > > > ‘mq_module1’ > > > Mercury/cs/mq.c:764:1: error: invalid storage class for function > > > ‘mq_module1’ > > > ... > > > > > > > > > > > > The function in question is this: > > > > > > :- pragma foreign_code("C", > > > " > > > char * null_to_empty(char * str) > > > { > > > if (str == 0) { > > > MR_String str1 = MR_GC_malloc(1); > > > *str1 = (char) 0; > > > return str1; > > > } else { > > > return str; > > > } > > > "). > > The bug is in your code: the left brace that starts the C function > has no matching right brace. The C compiler complains about > the following C functions because it thinks that they are being > declared INSIDE the null_to_empty function. Oops... > In the future, when reporting a possible problem with an error message > that mentions some definitions (mq_module0 and mq_module1), > it would help if you included the CODE OF THOSE DEFINITIONS, > and not the definition of something unrelated, such as null_to_empty. Do you mean this: MR_BEGIN_MODULE(mq_module0) MR_init_entry1(mq__setup_mqs_5_0); MR_INIT_PROC_LAYOUT_ADDR(mercury__mq__setup_mqs_5_0); MR_init_label6(mq__setup_mqs_5_0, 2,5,14,3,8,10) MR_BEGIN_CODE There is no other definition of mq_module0. null_to_empty isn't unrelated. There is the line "In function ‘null_to_empty’:" C compiler output. Cheers, Volker _______________________________________________ users mailing list [email protected] https://lists.mercurylang.org/listinfo/users
signature.asc
(application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEE6QXGh82Ov3+2nrxp+K4ydFOsHoUFAmP856kACgkQ+K4ydFOs HoVw0xAAlzwDWRqqc6wGs2DNCQDT4IY7OTXgX73EkEP9AClL//3fy7wuTbCVlt/Z Cs3gJ9N9JIPxzY2miZhHjpestxQzjuHTk5HsDJWwBsVQyiAQJEx8tTXsTjEbD01l CAI0d9/vUii33g+nvmQ8UAnsFkkJaB3CDBE+4ecEBqurVdP/5DCPiAQ6WN2j76sP PrJg9Tp/Wk9IMla69cdTyTv7ZgJ5mcy9Myhx1QZ2/pDrRXTmwnDIQC9kLZj0V7PB zG0tJWAxPHX15U0aiwhGHGY8dnbBNJHzlTmUNw1TK76mcDESfkECWb/4WDdW5ryV 3d1uNEvODmwzw9Zy5N1GVmzx99btZveVHbxSjYOn3rSzDTctnOKE0aB9VgjegYtL IlMckg5NYWVpHNL8M4AElMGPTLzQaQLe2gzvgp9C1sWNC2seXIfSBoaEaU9nVwyc Vs5xLectRktnD8oP+0AO+ngyJNGQ118FIvXJvAwJaP2jNvS8gbthObYv9zv6J4UV 1bBXl3AgJ9/GFRnJ2NwTN5Et39wGtvjQm8z2iCQ7mUGJdAP8H1PvB8WV3AI6JGf5 Mlur5plmidcHZYZxNsZmLX8SVvMu9ZLehcBG5uIQc1lsLNtB901quDsCYxnd9KcS nGAoJGYPuqu8RRbnGclT0tfKCKnlv6PeJxAFIykIMYcD3+tjSHs= =ZSHN -----END PGP SIGNATURE-----