Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warnings #3

Open
renzenicolai opened this issue Sep 2, 2024 · 0 comments
Open

Warnings #3

renzenicolai opened this issue Sep 2, 2024 · 0 comments

Comments

@renzenicolai
Copy link

	add_compile_options(
		# General
		-Wall												# Enable warnings for common coding mistakes or potential errors.
		-Wextra												# Extensions for -Wall.
		$<$<BOOL:${WARNING_AS_ERROR}>:-Werror>				# Treat warnings as errors to fail the build in case of warnings.
		-Wpedantic											# Warn for now standard C++.
		$<$<COMPILE_LANGUAGE:C>:-Werror=implicit-function-declaration> # Calling functions that don't exist are errors
		$<$<COMPILE_LANGUAGE:C>:-Werror=incompatible-pointer-types>
		$<$<COMPILE_LANGUAGE:C>:-Werror=int-conversion>
		# Type conversion
		-Wconversion										# Warn about implicit type conversions which (may) change the value.
		-Wsign-conversion									# Warn about implicit sign conversions.
		-Wdouble-promotion									# Warn about floats being implictly converted to doubles.
		-Wfloat-equal										# Warn about floatint point values used in equality tests.
		-Wpointer-arith										# Warn when sizeof(void) is used (directly or indirectly).
		# -Wcast-qual											# Warn when casting removes a type qualifier from a pointer.
		-Wcast-align										# Warn when casting a pointers changes the alignment of the pointee.
		$<$<COMPILE_LANGUAGE:C>:-Wbad-function-cast>		# Warn about casts to function pointers.
		-Wstrict-overflow=2									# Warn about optimizations where signed overflow is assumed not to occour.
		# Misc
		-Wshadow											# Warn about duplicated variable names.
		# -Wswitch-enum										# Warn about switch statements not using all possible enum values.
		-Wimplicit-fallthrough								# Warn about implicit, un-annotated, fallthroughs.
		-Wnull-dereference									# Warn about possible null pointer dereference code paths.
		-Wundef												# Warn when undefined macros are used (implicit conversion to 0.)
		$<$<COMPILE_LANGUAGE:C>:-Wstrict-prototypes>		# Warn when a function declaration misses argument types.
		-Wunused											# Warn about any unused parameter/function/variable/etc...
		-Wmisleading-indentation							# Warn about indentation giving the impression of scope.
		-Winline											# Warn when desired inlining is not possible.
		# Strings related
		-Wvla												# Warn about variable-length arrays being used.
		-Wwrite-strings										# Warn when attempting to write to a string constant.
		-Wformat=2											# Verify printf/scanf/.. arguments and format strings match.
		# Code generation
		-fno-common													# Warn when global variables are not unique (and unintentionaly merged.)
		-fstack-usage												# Generate stack depth information.
		-fvisibility=hidden											# Sets the default symbol visibility to hidden.
		-fwrapv														# Assume signed arithmatic may wrap around.
		-ftrivial-auto-var-init=zero								# Ensure automatic variables are always initialized.
	)

Would be nice to solve some of the issues pointed out when compiling with these extra warnings enabled 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant