On 5/5/21 2:10 PM, Philippe Mathieu-Daudé wrote:
The compiler isn't clever enough to figure 'SEG_CHUNK_SIZE' is
a constant! Help it by using a definitions instead.

This isn't about being clever or not, it's semantics.

In C++, "const int" is a proper constant, but in C it is a variable with a constant value. Thus the use of the symbol in the array bounds is, by definition, variable.


-    const int SEG_CHUNK_SIZE = 256;
+#define SEG_CHUNK_SIZE 256

enum { SEG_CHUNK_SIZE = 256 };

would retain the function scope for the symbol, if that's desirable.


r~

Reply via email to