Explicitly declare void for all void parameter functions (#628)

Apparently in C, if you have `void test();`, it's completely okay to do
`test(2);`. The function will take in the argument, but just discard it
and throw it away. It's like a trash can, and a rude one at that. If you
declare it like `void test(void);`, this is prevented.

This is not a problem in C++ - doing `void test();` and `test(2);` is
guaranteed to result in a compile error (this also means that right now,
at least in all `.cpp` files, nobody is ever calling a void parameter
function with arguments and having their arguments be thrown away).
However, we may not be using C++ in the future, so I just want to lay
down the precedent that if a function takes in no arguments, you must
explicitly declare it as such.

I would've added `-Wstrict-prototypes`, but it produces an annoying
warning message saying it doesn't work in C++ mode if you're compiling
in C++ mode. So it can be added later.
This commit is contained in:
Misa
2021-02-25 14:23:59 -08:00
committed by GitHub
parent 0e313d0d75
commit 6a3a1fe147
53 changed files with 439 additions and 439 deletions

View File

@@ -54,7 +54,7 @@ bool entityclass::checktowerspikes(int t)
return false;
}
void entityclass::init()
void entityclass::init(void)
{
platformtile = 0;
customplatformtile=0;
@@ -82,7 +82,7 @@ void entityclass::init()
k = 0;
}
void entityclass::resetallflags()
void entityclass::resetallflags(void)
{
SDL_memset(flags, false, sizeof(flags));
}
@@ -1093,7 +1093,7 @@ bool entityclass::disableentity(int t)
return true;
}
void entityclass::removeallblocks()
void entityclass::removeallblocks(void)
{
blocks.clear();
}
@@ -3787,7 +3787,7 @@ void entityclass::animateentities( int _i )
}
}
int entityclass::getcompanion()
int entityclass::getcompanion(void)
{
//Returns the index of the companion with rule t
for (size_t i = 0; i < entities.size(); i++)
@@ -3801,7 +3801,7 @@ int entityclass::getcompanion()
return -1;
}
int entityclass::getplayer()
int entityclass::getplayer(void)
{
//Returns the index of the first player entity
for (size_t i = 0; i < entities.size(); i++)
@@ -3815,7 +3815,7 @@ int entityclass::getplayer()
return -1;
}
int entityclass::getscm()
int entityclass::getscm(void)
{
//Returns the supercrewmate
for (size_t i = 0; i < entities.size(); i++)
@@ -3895,7 +3895,7 @@ int entityclass::getcustomcrewman( int t )
return 0;
}
int entityclass::getteleporter()
int entityclass::getteleporter(void)
{
for (size_t i = 0; i < entities.size(); i++)
{
@@ -3986,7 +3986,7 @@ int entityclass::checktrigger(int* block_idx)
return -1;
}
int entityclass::checkactivity()
int entityclass::checkactivity(void)
{
//Returns an int player entity (rule 0) collides with an activity
for(size_t i=0; i < entities.size(); i++)
@@ -4591,7 +4591,7 @@ void entityclass::customwarplinecheck(int i) {
}
}
void entityclass::entitycollisioncheck()
void entityclass::entitycollisioncheck(void)
{
for (size_t i = 0; i < entities.size(); i++)
{