File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change 13
13
#include <stdlib.h>
14
14
#include <stdio.h>
15
15
#include <string.h>
16
+ #ifdef WIN32
17
+ #include <fcntl.h>
18
+ #include <io.h>
19
+ #endif
16
20
#include <grass/gis.h>
17
21
#include <grass/raster.h>
18
22
#include <grass/display.h>
@@ -131,10 +135,14 @@ static int cell_draw( char *name,
131
135
blu = G_malloc ( ncols );
132
136
set = G_malloc ( ncols );
133
137
134
- /* some buggy C libraries require BOTH setmode() and fdopen(bin) ? */
135
- //setmode(fileno(stdin), O_BINARY);
136
- fo = fdopen ( fileno ( stdout ), "wb" );
137
-
138
+ /* some buggy C libraries require BOTH setmode() and fdopen(bin) */
139
+ #ifdef WIN32
140
+ if ( _setmode ( _fileno ( stdout ), _O_BINARY ) == -1 )
141
+ G_fatal_error ( "Cannot set stdout mode" );
142
+ #endif
143
+ // Unfortunately this is not sufficient on Windows to switch stdout to binary mode
144
+ fo = fdopen (fileno (stdout ), "wb" );
145
+
138
146
/* loop for array rows */
139
147
for ( row = 0 ; row < nrows ; row ++ )
140
148
{
You can’t perform that action at this time.
0 commit comments