views:

147

answers:

3

Here is some code I could not get to format properly in markdown, this is straight C code, pasted into the text box with the '4 spaces' format to denote code:

#define PRINT(x, format, ...) \
    if ( x ) { \
        if ( debug_fd != NULL ) { \
            fprintf(debug_fd, format, ##__VA_ARGS__); \
        } \
        else { \
            fprintf(stdout, format, ##__VA_ARGS__); \
        } \
    }

It seems as though the '\' causes the newlines to be ignored. Ok fine, I am used to this in bash, but if I put '\' the second one doesn't show up. As if the second one is absorbed. Am I missing something ?

+2  A: 

Add at least four spaces or a hard tab before each line of the code. Like this:

#define PRINT(x, format, ...) \
if ( x ) { \
    if ( debug_fd != NULL ) { \
        fprintf(debug_fd, format, ##VA_ARGS); \
} \
else { \
    fprintf(stdout, format, ##VA_ARGS); \
} \
}
Julio César
A: 
#define PRINT(x, format, ...)
if ( x ) 
{
    if ( debug_fd != NULL ) 
    { 
        fprintf(debug_fd, format, ##VA_ARGS); 
    } 
    else 
    { 
        fprintf(stdout, format, ##VA_ARGS); 
    } 
}
FlySwat
+2  A: 
OwenP