FLTK logo

[master] c8c1f51 - Fix MSVC "fileno" warnings in fluid

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.commit  ]
 
Previous Message ]Next Message ]

[master] c8c1f51 - Fix MSVC "fileno" warnings in fluid "Albrecht Schlosser" Aug 30, 2021  
 
commit c8c1f51db7bd89291d2f7552e82e3724fcdaec8b
Author:     Albrecht Schlosser <albrechts.fltk@online.de>
AuthorDate: Mon Aug 30 23:23:59 2021 +0200
Commit:     Albrecht Schlosser <albrechts.fltk@online.de>
CommitDate: Mon Aug 30 23:45:16 2021 +0200

    Fix MSVC "fileno" warnings in fluid

 fluid/alignment_panel.fl |  4 +---
 fluid/fluid.cxx          | 17 ++++++++++++++---
 fluid/widget_panel.fl    |  2 +-
 3 files changed, 16 insertions(+), 7 deletions(-)

diff --git fluid/alignment_panel.fl fluid/alignment_panel.fl
index cb9b111..20b09b5 100644
--- fluid/alignment_panel.fl
+++ fluid/alignment_panel.fl
@@ -764,8 +764,7 @@ Default is on.} xywh {245 366 100 25} down_box BORDER_BOX
         }
       }
     }
-
-        Fl_Group {} {
+    Fl_Group {} {
       label {Scaling Factor Options} open
       xywh {10 421 380 66} box GTK_DOWN_BOX labelfont 2 align 21
     } {
@@ -797,7 +796,6 @@ Default is on.} xywh {245 442 100 25} down_box BORDER_BOX
         }
       }
     }
-
     Fl_Choice wUserOrSystem {
       callback {refreshUI();} open
       tooltip {Change settings for the current user, or default values for all users of this computer. Individual users can override system options, if they set their options to specific values (not 'default').} xywh {10 496 141 25} down_box BORDER_BOX
diff --git fluid/fluid.cxx fluid/fluid.cxx
index 0e12bba..0c1647b 100644
--- fluid/fluid.cxx
+++ fluid/fluid.cxx
@@ -1347,9 +1347,20 @@ public:
   //not necessary here: FILE * fl_fopen (const char *file, const char *mode="r");
   int  close();
 
-  FILE * desc() const { return _fpt;} // non null if file is open
+  FILE * desc() const { return _fpt;} // non-null if file is open
   char * get_line(char * line, size_t s) const {return _fpt ? fgets(line, (int)s, _fpt) : NULL;}
 
+  // returns fileno(FILE*):
+  // (file must be open, i.e. _fpt must be non-null)
+  // *FIXME* we should find a better solution for the 'fileno' issue
+  int fileno() const {
+#ifdef _MSC_VER
+    return _fileno(_fpt); // suppress MSVC warning
+#else
+    return ::fileno(_fpt);
+#endif
+  } // non null if file is open
+
 #if defined(_WIN32)  && !defined(__CYGWIN__)
 protected:
   HANDLE pin[2], pout[2], perr[2];
@@ -1490,7 +1501,7 @@ shell_pipe_cb(FL_SOCKET, void*) {
     shell_run_terminal->append(line);
   } else {
     // End of file; tell the parent...
-    Fl::remove_fd(fileno(s_proc.desc()));
+    Fl::remove_fd(s_proc.fileno());
     s_proc.close();
     shell_run_terminal->append("... END SHELL COMMAND ...\n");
   }
@@ -1526,7 +1537,7 @@ do_shell_command(Fl_Return_Button*, void*) {
   }
   shell_run_window->show();
 
-  Fl::add_fd(fileno(s_proc.desc()), shell_pipe_cb);
+  Fl::add_fd(s_proc.fileno(), shell_pipe_cb);
 
   while (s_proc.desc()) Fl::wait();
 
diff --git fluid/widget_panel.fl fluid/widget_panel.fl
index ab45161..38a5b34 100644
--- fluid/widget_panel.fl
+++ fluid/widget_panel.fl
@@ -134,7 +134,7 @@ Use Ctrl-J for newlines.} xywh {95 40 190 20} labelfont 1 labelsize 11 when 1 te
           } {
             MenuItem {} {
               label {   Image Alignment   }
-              user_data (fl_intptr_t)0xFFFFFFFF
+              user_data {(fl_intptr_t)0xFFFFFFFF}
               xywh {145 145 100 20} labelfont 2 labelsize 11 deactivate
             }
             MenuItem {} {
Direct Link to Message ]
 
     
Previous Message ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.