Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

configure.ac G_HAVE_ISO_VARARGS problems #8587

Closed
jaykrell opened this issue May 5, 2018 · 3 comments
Closed

configure.ac G_HAVE_ISO_VARARGS problems #8587

jaykrell opened this issue May 5, 2018 · 3 comments
Assignees

Comments

@jaykrell
Copy link
Contributor

jaykrell commented May 5, 2018

In configure.ac we have:

AC_MSG_CHECKING(for varargs macros)
AC_TRY_COMPILE([],[
int foo (int i, int j);
#define bar(...) foo (1, __VA_ARGS__)
void main () {
	 bar (2);
}
],have_iso_varargs=yes,have_iso_varargs=no)
AC_MSG_RESULT($have_iso_varargs)
G_HAVE_ISO_VARARGS=0
if test "x$have_iso_varargs" = "xyes"; then
   G_HAVE_ISO_VARARGS=1
fi
AC_SUBST(G_HAVE_ISO_VARARGS)

This does not work in the way intended.
A main() wrapper is supplied and it tries to compile:

int
main ()
{
		int foo (int i, int j);
		#define bar(...) foo (1, __VA_ARGS__)
		void main () {
			 bar (2);
		}
  ;
  return 0;
}

giving:

1.c:7:14: error: function definition is not allowed here
void main () {
@jaykrell jaykrell self-assigned this May 5, 2018
jaykrell added a commit to jaykrell/mono that referenced this issue May 5, 2018
Change 3 ifdef versions to one portable one.
Remove supporting autoconf that did not work as intended.
See mono#8587.
@marek-safar
Copy link
Member

From @jaykrell comment

Sometimes gcc allows nested functions, sometimes not, i.e. Apple configuration.

Solution is use newer-fangled AC_COMPILE_IFELSE.
Or rename main and put it in the first parameter.
Or remove the entire thing, really, and see what @luhenry did here:

#if defined(_MSC_VER) && (_MSC_VER < 1910)
#define g_assertf(x, format, ...) (G_LIKELY((x)) ? 1 : (g_assertion_message ("* Assertion at %s:%d, condition `%s' not met, function:%s, " format "\n", __FILE__, __LINE__, #x, __func__, __VA_ARGS__), 0))
#else
#define g_assertf(x, format, ...) (G_LIKELY((x)) ? 1 : (g_assertion_message ("* Assertion at %s:%d, condition `%s' not met, function:%s, " format "\n", __FILE__, __LINE__, #x, __func__, ##__VA_ARGS__), 0))
#endif

Also I don't think the intermediate have_iso_varargs is needed.
Also in the config.h you can just say #if @foo@, you don't need #if @foo@ == 1.

@jaykrell
Copy link
Contributor Author

jaykrell commented May 7, 2018

Or if the parameters end up adjacent, unlike g_assertf, just consider "format" part of "..." and just say VA_ARGS to take both, with whatever comma the user put in.
The wierdness in g_assertf is justified, unlike in other places, because the parameters get split.

jaykrell added a commit that referenced this issue May 31, 2018
Change 3 ifdef versions to one portable one.
Remove supporting autoconf that did not work as intended.
See #8587.
@jaykrell
Copy link
Contributor Author

Fixed.

picenka21 pushed a commit to picenka21/runtime that referenced this issue Feb 18, 2022
Change 3 ifdef versions to one portable one.
Remove supporting autoconf that did not work as intended.
See mono/mono#8587.

Commit migrated from mono/mono@f3157ed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants