After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 434515 - Support conditional compilation
Support conditional compilation
Status: RESOLVED FIXED
Product: vala
Classification: Core
Component: Parser
0.4.x
Other All
: Low enhancement
: ---
Assigned To: Jürg Billeter
Vala maintainers
Depends on:
Blocks: 575591
 
 
Reported: 2007-04-30 07:15 UTC by Jürg Billeter
Modified: 2009-04-03 07:41 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Jürg Billeter 2007-04-30 07:15:06 UTC
Add support for basic conditional compilation constructs.
Comment 1 Jürg Billeter 2007-11-24 08:54:49 UTC
Maybe use attributes instead of preprocessor-like constructs.
Comment 2 Maciej (Matthew) Piechotka 2008-01-14 08:02:40 UTC
It would be nice to have a support for macros.

1. #include <config.h>
2. Many headers define macros

However, from the writer side it may look different (ie. I do not propose to include C preprocesor - I propose the evaluation to C preprocesor).
Comment 3 Jürg Billeter 2008-01-17 22:51:47 UTC
2008-01-17  Jürg Billeter  <j@bitron.ch>

	* vala/parser.y, vala/valacodecontext.vala, compiler/valacompiler.vala:
	  add [Conditional (condition = "CONDITION")] attribute for methods,
	  fixes bug 434515

Fixed in r848.
Comment 4 Marc-Andre Lureau 2008-10-18 15:31:28 UTC
Is this feature still supported?

I tried to add a test in vala-tests, but that didn't seems to work as expected.

It seems that the function ignore_node is no longer called anywhere.

Jurg, could you comment?

beta@pipo ~/git/gnome2/vala (master)$ ack-grep ignore_node
vala/valacodecontext.h
78:gboolean vala_code_context_ignore_node (ValaCodeContext* self, ValaCodeNode* node);

vala/valacodecontext.c
486:gboolean vala_code_context_ignore_node (ValaCodeContext* self, ValaCodeNode* node) {

vala/vala.gidl
1069:		<method name="ignore_node" symbol="vala_code_context_ignore_node">

build/vala/vala.gidl
1069:		<method name="ignore_node" symbol="vala_code_context_ignore_node">
Comment 5 Jürg Billeter 2008-10-25 06:18:12 UTC
It's not working anymore for some time, however, I don't think we should just readd it as the implementation was questionable. As Vala projects usually distribute the generated C code, it doesn't make much sense to ignore nodes within valac. It would probably be a lot more useful to process everything in valac, however, make it possible to add #ifdef directives in the generated C code. This will probably require more changes in the compiler and I'm not sure about the syntax yet, any suggestions?
Comment 6 Jürg Billeter 2009-01-11 14:18:08 UTC
Generating generic C code with #ifdefs sounds like a complex task, I'm not expecting to get something like this into the compiler anytime soon.

In the end it should not be necessary to distribute generated C code for most projects when we have a stable Vala compiler. In that case, supporting conditional compilation would be a lot easier. Maybe we should just implement that so that we can cover at least some use cases.

For that purpose, the C# syntax makes sense to me. This would mean adding #if, #endif - without using a full preprocessor and without macro support.
Comment 7 Jürg Billeter 2009-04-03 07:41:28 UTC
commit 3f0e7474f8cb772cdd7e19f1e062d4706f8e598b
Author: Jürg Billeter <j@bitron.ch>
Date:   Fri Apr 3 09:37:00 2009 +0200

    Support conditional compilation
    
    Add -D SYMBOL commandline option to define conditional symbols.
    Support precondition directives #if, #elif, #else, and #endif.
    Fixes bug 434515.