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,7 +339,10 @@ void MarlinSettings::postprocess() {
339 339
 
340 340
     #if ENABLED(MESH_BED_LEVELING)
341 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 346
       const bool leveling_is_on = TEST(mbl.status, MBL_STATUS_HAS_MESH_BIT);
344 347
       const uint8_t mesh_num_x = GRID_MAX_POINTS_X, mesh_num_y = GRID_MAX_POINTS_Y;
345 348
       EEPROM_WRITE(leveling_is_on);
@@ -381,7 +384,10 @@ void MarlinSettings::postprocess() {
381 384
 
382 385
     #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
383 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 391
       const uint8_t grid_max_x = GRID_MAX_POINTS_X, grid_max_y = GRID_MAX_POINTS_Y;
386 392
       EEPROM_WRITE(grid_max_x);            // 1 byte
387 393
       EEPROM_WRITE(grid_max_y);            // 1 byte

Loading…
Cancel
Save