Everywhere: Warn on function definitions without prototypes

If no header includes the prototype of a function, then it cannot be
used from outside the translation unit it was defined in. In that case,
it should be marked as `static`, in order to avoid possible ODR
problems, unnecessary exported symbols, and allow the compiler to better
optimize those.

If this warning triggers in a function defined in a header, `inline`
needs to be added, otherwise if the header is included in more than one
TU, it will fail to link with a duplicate definition error.

The reason this diff got so big is that Lagom-only code wasn't built
with this flag even in Serenity times.
This commit is contained in:
Daniel Bertalan
2024-07-14 18:29:33 +02:00
parent 7fe82a1cda
commit c62240aa80
24 changed files with 146 additions and 97 deletions

View File

@@ -10,7 +10,7 @@
namespace Core {
ErrorOr<VkInstance> create_instance(uint32_t api_version)
static ErrorOr<VkInstance> create_instance(uint32_t api_version)
{
VkInstance instance;
@@ -35,7 +35,7 @@ ErrorOr<VkInstance> create_instance(uint32_t api_version)
return instance;
}
ErrorOr<VkPhysicalDevice> pick_physical_device(VkInstance instance)
static ErrorOr<VkPhysicalDevice> pick_physical_device(VkInstance instance)
{
uint32_t device_count = 0;
vkEnumeratePhysicalDevices(instance, &device_count, nullptr);
@@ -65,7 +65,7 @@ ErrorOr<VkPhysicalDevice> pick_physical_device(VkInstance instance)
VERIFY_NOT_REACHED();
}
ErrorOr<VkDevice> create_logical_device(VkPhysicalDevice physical_device)
static ErrorOr<VkDevice> create_logical_device(VkPhysicalDevice physical_device)
{
VkDevice device;