Skip to content

WIP: Support `define' expressions in global scope of source files

Rico Tzschichholz requested to merge wip/defines into master

This allow the following syntax:

define G_LOG_DOMAIN = "vala", VALA_PI = 3.1415;
define ENABLE_SOMETHING;

void main () {
	string foo;
}
/* test.c generated by valac, the Vala compiler
 * generated from test.vala, do not modify */

#define G_LOG_DOMAIN "vala"
#define VALA_PI 3.1415
#define ENABLE_SOMETHING

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

#define _g_free0(var) (var = (g_free (var), NULL))

void _vala_main (void);

void
_vala_main (void)
{
	gchar* foo = NULL;
	_g_free0 (foo);
}

int
main (int argc,
      char ** argv)
{
	_vala_main ();
	return 0;
}

Merge request reports