MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / getLimitsDefines

Method getLimitsDefines

lib/platform.cpp:317–455  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

315}
316
317std::string Platform::getLimitsDefines(bool c99) const
318{
319 std::string s;
320
321 // climits / limits.h
322 s += "CHAR_BIT=";
323 s += std::to_string(char_bit);
324 s += ";SCHAR_MIN=";
325 s += std::to_string(min_value(char_bit));
326 s += ";SCHAR_MAX=";
327 s += std::to_string(max_value(char_bit));
328 s += ";UCHAR_MAX=";
329 s += std::to_string(max_value(char_bit+1));
330 s += ";CHAR_MIN=";
331 if (defaultSign == 'u')
332 s += std::to_string(min_value(char_bit));
333 else
334 s += std::to_string(0);
335 s += ";CHAR_MAX=";
336 if (defaultSign == 'u')
337 s += std::to_string(max_value(char_bit+1));
338 else
339 s += std::to_string(max_value(char_bit));
340 // TODO
341 //s += ";MB_LEN_MAX=";
342 s += ";SHRT_MIN=";
343 s += std::to_string(min_value(short_bit));
344 s += ";SHRT_MAX=";
345 s += std::to_string(max_value(short_bit));
346 s += ";USHRT_MAX=";
347 s += std::to_string(max_value(short_bit+1));
348 s += ";INT_MIN=";
349 s += "(-" + std::to_string(max_value(int_bit)) + " - 1)";
350 s += ";INT_MAX=";
351 s += std::to_string(max_value(int_bit));
352 s += ";UINT_MAX=";
353 s += std::to_string(max_value(int_bit+1));
354 s += ";LONG_MIN=";
355 s += "(-" + std::to_string(max_value(long_bit)) + "L - 1L)";
356 s += ";LONG_MAX=";
357 s += std::to_string(max_value(long_bit)) + "L";
358 s += ";ULONG_MAX=";
359 s += std::to_string(max_value_unsigned(long_bit)) + "UL";
360 if (c99) {
361 s += ";LLONG_MIN=";
362 s += "(-" + std::to_string(max_value(long_long_bit)) + "LL - 1LL)";
363 s += ";LLONG_MAX=";
364 s += std::to_string(max_value(long_long_bit)) + "LL";
365 s += ";ULLONG_MAX=";
366 s += std::to_string(max_value_unsigned(long_long_bit)) + "ULL";
367 }
368
369 // cstdint / stdint.h
370 // FIXME: these are currently hard-coded in std.cfg
371 /*
372 INTMAX_MIN
373 INTMAX_MAX
374 UINTMAX_MAX

Callers 2

createDUIFunction · 0.80
limitsDefinesMethod · 0.80

Calls 2

max_valueFunction · 0.85
max_value_unsignedFunction · 0.85

Tested by 1

limitsDefinesMethod · 0.64