App-UnifdefPlus
view release on metacpan or search on metacpan
t/test1.c.expectedout view on Meta::CPAN
/* 2.1 FOO defined (V) */
/* 2.2 BAR not defined, FOO defined (V) */
#if defined FOOBAR // (V)
/* 2.3 FOOBAR defined (V) */
#elif defined FOOBAR2 // (V)
/* 2.3 FOOBAR not defined, FOOBAR2 defined (V) */
#else // (V)
/* 2.3 FOOBAR and FOOBAR2 not defined (V) */
#endif // (V)
/* Checking that #ifs in comment are not simplified:
#if defined BAR
... some text
#endif
*/
// #if defined BAR
// some comment
// #endif
/* 3. Check nesting: */
/* 3.1 FOO defined, but not BAR (V) */
#if defined FOOBAR
/* 3.1 FOO and FOOBAR defined (V) */
#else
/* 3.1 FOO defined but not FOOBAR (V) */
#endif
#if defined FOOBAR //(V)
/* 3.1 BAR not defined, FOOBAR defined (V) */
#else //(V)
/* 3.1 BAR and FOOBAR not defined (V) */
#endif //(V)
/* 4: Check complex expressions with #if: */
// note: && has higher precedence than ||:
/* 4.1 FOO or BAR are undefined (V) */
/* 4.2 FOO or BAR are defined (V) */
/* 4.3 #if defined(D1) && defined(D2) || defined(U1) (V)*/
/* 4.4 #if defined(D1) || defined(D2) && defined(U1) (V) */
/* 4.5 #else (#if (defined(D1) || defined(D2)) && defined(U1)) (V)*/
#if defined(FOOBAR)
/* 4.6 #if (defined(D1) || defined(D2)) && defined(U1) || defined(FOOBAR) (V) */
#else
/* 4.6 #else */
#endif
#if (FOOBAR > 3 * (9 - 2) ) // eol comment
/* 4.20 complex... -- should resolve to #if ( FOOBAR > 3 * (9 - 2) ) // eol comment */
#else
/* 4.20 #else */
#endif
#if U1 > (3 + 2) // (4.21 condition simplifies)
/* 4.21 line will appear */
#else
/* 4.21 line will appear, as an else to the unknown */
#endif
// Note: known bug: whitespace at opening brace is not being preserved...
// #if ( ( /*comment*/ FOOBAR > 3 * (9-2)) && defined(FOO) )
// does not preserve the comment or whitespaces.
( run in 0.732 second using v1.01-cache-2.11-cpan-98e64b0badf )