cgen icon indicating copy to clipboard operation
cgen copied to clipboard

Add default args to Define and make elselines optional in IfNdef/Ifdef

Open lokraszewski opened this issue 6 years ago • 1 comments

Some quality of life improvements. This allows you to write a common include guard pattern such as:

test = c.IfNDef('__HEADER__', 
	[
		c.Define('__HEADER__'), 
		c.Comment("Header content")
	])

print(test)

Which results in:

#ifndef __HEADER__
#define __HEADER__
/* Header content */
#endif

Also added some test for the new ifndef/ifdef functionality.

lokraszewski avatar Oct 07 '19 20:10 lokraszewski

@inducer let me know what you think of this! :smile:

lokraszewski avatar Oct 10 '19 10:10 lokraszewski