Browse Source

Replace c_assert hack with static_assert

Scott Lahteine 7 years ago
parent
commit
b98bc034ae
1 changed files with 8 additions and 2 deletions
  1. 8
    2
      Marlin/configuration_store.cpp

+ 8
- 2
Marlin/configuration_store.cpp View File

339
 
339
 
340
     #if ENABLED(MESH_BED_LEVELING)
340
     #if ENABLED(MESH_BED_LEVELING)
341
       // Compile time test that sizeof(mbl.z_values) is as expected
341
       // Compile time test that sizeof(mbl.z_values) is as expected
342
-      typedef char c_assert[(sizeof(mbl.z_values) == (GRID_MAX_POINTS_X) * (GRID_MAX_POINTS_Y) * sizeof(dummy)) ? 1 : -1];
342
+      static_assert(
343
+        sizeof(mbl.z_values) == (GRID_MAX_POINTS_X) * (GRID_MAX_POINTS_Y) * sizeof(mbl.z_values[0][0]),
344
+        "MBL Z array is the wrong size."
345
+      );
343
       const bool leveling_is_on = TEST(mbl.status, MBL_STATUS_HAS_MESH_BIT);
346
       const bool leveling_is_on = TEST(mbl.status, MBL_STATUS_HAS_MESH_BIT);
344
       const uint8_t mesh_num_x = GRID_MAX_POINTS_X, mesh_num_y = GRID_MAX_POINTS_Y;
347
       const uint8_t mesh_num_x = GRID_MAX_POINTS_X, mesh_num_y = GRID_MAX_POINTS_Y;
345
       EEPROM_WRITE(leveling_is_on);
348
       EEPROM_WRITE(leveling_is_on);
381
 
384
 
382
     #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
385
     #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
383
       // Compile time test that sizeof(bed_level_grid) is as expected
386
       // Compile time test that sizeof(bed_level_grid) is as expected
384
-      typedef char c_assert[(sizeof(bed_level_grid) == (GRID_MAX_POINTS_X) * (GRID_MAX_POINTS_Y) * sizeof(dummy)) ? 1 : -1];
387
+      static_assert(
388
+        sizeof(bed_level_grid) == (GRID_MAX_POINTS_X) * (GRID_MAX_POINTS_Y) * sizeof(bed_level_grid[0][0]),
389
+        "Bilinear Z array is the wrong size."
390
+      );
385
       const uint8_t grid_max_x = GRID_MAX_POINTS_X, grid_max_y = GRID_MAX_POINTS_Y;
391
       const uint8_t grid_max_x = GRID_MAX_POINTS_X, grid_max_y = GRID_MAX_POINTS_Y;
386
       EEPROM_WRITE(grid_max_x);            // 1 byte
392
       EEPROM_WRITE(grid_max_x);            // 1 byte
387
       EEPROM_WRITE(grid_max_y);            // 1 byte
393
       EEPROM_WRITE(grid_max_y);            // 1 byte

Loading…
Cancel
Save