FLTK logo

[master] 5810eda - Fix remaining VS compiler warnings in test programs

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] 5810eda - Fix remaining VS compiler warnings in test programs "Albrecht Schlosser" Nov 16, 2021  
 
commit 5810edaf84707563b452bd0e4b6120909b8ef3ea
Author:     Albrecht Schlosser <albrechts.fltk@online.de>
AuthorDate: Tue Nov 16 21:05:33 2021 +0100
Commit:     Albrecht Schlosser <albrechts.fltk@online.de>
CommitDate: Tue Nov 16 21:25:19 2021 +0100

    Fix remaining VS compiler warnings in test programs

 test/blocks.cxx   | 20 ++++++++++----------
 test/editor.cxx   | 14 +++++++-------
 test/fractals.cxx |  6 +++---
 3 files changed, 20 insertions(+), 20 deletions(-)

diff --git test/blocks.cxx test/blocks.cxx
index 7faa4c9..75a2a1a 100644
--- test/blocks.cxx
+++ test/blocks.cxx
@@ -60,9 +60,9 @@
 // (b) click on a "normal block", destroy this one and adjacent blocks
 // (c) click on a "bomb", destroy all blocks of the same color
 
-#define LEVEL_FACTOR    0.90    // was: 0.95
-#define NORMAL_FACTOR   0.999
-#define BOMB_FACTOR     0.995
+#define LEVEL_FACTOR    0.900f    // was: 0.95
+#define NORMAL_FACTOR   0.999f
+#define BOMB_FACTOR     0.995f
 
 // Set this to 1 to debug the timer callback (should be 0)
 #define DEBUG_TIMER     0
@@ -309,8 +309,8 @@ BlockSound::BlockSound() {
 
     for (int j = max_sample; j > 0; j --, sample_ptr ++) {
       float freq = (float)j / (float)max_sample;
-      float volume = 32767.0 * (0.5 * sqrt(freq) + 0.5);
-      float sample = 0.0001 * ((rand() % 20001) - 10000);
+      float volume = float(32767.0 * (0.5 * sqrt(freq) + 0.5));
+      float sample = float(0.0001 * ((rand() % 20001) - 10000));
 
       *sample_ptr = (int)(volume * freq * sample +
                           (1.0 - freq) * sample_ptr[-2]);
@@ -785,12 +785,12 @@ int BlockWindow::handle(int event) {
         count --;
 
         if (b->bomb) {
-          sound_->play_explosion(0.19 + 0.005 * count);
+          sound_->play_explosion(float(0.19 + 0.005 * count));
 
           interval_ *= BOMB_FACTOR;
           score_ += count;
         } else {
-          sound_->play_explosion(0.09 + 0.005 * count);
+          sound_->play_explosion(float(0.09 + 0.005 * count));
 
           interval_ *= NORMAL_FACTOR;
           score_ += count * count;
@@ -841,11 +841,11 @@ void BlockWindow::init() {
 // Start a new game...
 void BlockWindow::new_game() {
   // Seed the random number generator...
-  srand(time(NULL));
+  srand((unsigned int)time(NULL));
 
   init();
 
-  interval_       = 0.1;
+  interval_       = 0.1f;
   opened_columns_ = 0;
 
   strcpy(title_, "Level: 1");
@@ -1006,7 +1006,7 @@ void BlockWindow::timeout_cb(BlockWindow *bw) {
 
       if (bw->num_columns_ == BLOCK_COLS) {
         bw->interval_ = -1.0;
-        bw->sound_->play_explosion(0.8);
+        bw->sound_->play_explosion(0.8f);
         bw->play_button_->label("@>");
       } else {
         bw->opened_columns_ ++;
diff --git test/editor.cxx test/editor.cxx
index 3170362..eb45de7 100644
--- test/editor.cxx
+++ test/editor.cxx
@@ -658,8 +658,8 @@ void find2_cb(Fl_Widget* w, void* v) {
   int found = textbuf->search_forward(pos, e->search, &pos);
   if (found) {
     // Found a match; select and update the position...
-    textbuf->select(pos, pos+strlen(e->search));
-    e->editor->insert_position(pos+strlen(e->search));
+    textbuf->select(pos, pos + (int)strlen(e->search));
+    e->editor->insert_position(pos + (int)strlen(e->search));
     e->editor->show_insert_position();
   }
   else fl_alert("No occurrences of \'%s\' found!", e->search);
@@ -773,11 +773,11 @@ void replace2_cb(Fl_Widget*, void* v) {
 
   if (found) {
     // Found a match; update the position and replace text...
-    textbuf->select(pos, pos+strlen(find));
+    textbuf->select(pos, pos + (int)strlen(find));
     textbuf->remove_selection();
     textbuf->insert(pos, replace);
-    textbuf->select(pos, pos+strlen(replace));
-    e->editor->insert_position(pos+strlen(replace));
+    textbuf->select(pos, pos + (int)strlen(replace));
+    e->editor->insert_position(pos + (int)strlen(replace));
     e->editor->show_insert_position();
   }
   else fl_alert("No occurrences of \'%s\' found!", find);
@@ -807,10 +807,10 @@ void replall_cb(Fl_Widget*, void* v) {
 
     if (found) {
       // Found a match; update the position and replace text...
-      textbuf->select(pos, pos+strlen(find));
+      textbuf->select(pos, pos + (int)strlen(find));
       textbuf->remove_selection();
       textbuf->insert(pos, replace);
-      e->editor->insert_position(pos+strlen(replace));
+      e->editor->insert_position(pos + (int)strlen(replace));
       e->editor->show_insert_position();
       times++;
     }
diff --git test/fractals.cxx test/fractals.cxx
index 38ac384..bea5bf3 100644
--- test/fractals.cxx
+++ test/fractals.cxx
@@ -754,11 +754,11 @@ void MenuInit(void)
 /***************************************************************/
 
 // FLTK-style callbacks to Glut menu callback translators:
-void setlevel(Fl_Widget*, void *value) {setlevel(fl_intptr_t(value));}
+void setlevel(Fl_Widget*, void *value) {setlevel(fl_int(value));}
 
-void choosefract(Fl_Widget*, void *value) {choosefract(fl_intptr_t(value));}
+void choosefract(Fl_Widget*, void *value) {choosefract(fl_int(value));}
 
-void handlemenu(Fl_Widget*, void *value) {handlemenu(fl_intptr_t(value));}
+void handlemenu(Fl_Widget*, void *value) {handlemenu(fl_int(value));}
 
 #include <FL/Fl_Button.H>
 #include <FL/Fl_Group.H>
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'.