3 Commits

Author SHA1 Message Date
39540e9c3e add pragma macros,
silences -Wcast-function-type
2024-07-09 15:57:38 +01:00
af98dead75 swap blocks. 2024-07-09 15:11:48 +01:00
ad91a7f4e6 log fatal exit points 2024-07-09 13:18:57 +01:00
4 changed files with 26 additions and 15 deletions

View File

@@ -33,6 +33,6 @@ $(BIN_DIR) $(OBJ_DIR):
pwsh -Command New-Item -Path $@ -ItemType Directory pwsh -Command New-Item -Path $@ -ItemType Directory
clean: clean:
pwsh -Command Remove-Item -Recurse $(EXE), $(OBJ_DIR) pwsh -Command Remove-Item -Recurse $(EXE), $(OBJ_DIR) -force
-include $(OBJ:.o=.d) -include $(OBJ:.o=.d)

View File

@@ -20,6 +20,13 @@
#include "util.h" #include "util.h"
#include "log.h" #include "log.h"
#define PRAGMA_IgnoreWCastIncompatibleFuncTypes \
_Pragma("GCC diagnostic push") \
_Pragma("GCC diagnostic ignored \"-Wcast-function-type\"")
#define PRAGMA_Pop \
_Pragma("GCC diagnostic pop")
static T_VBVMR_INTERFACE iVMR; static T_VBVMR_INTERFACE iVMR;
static long initialize_dll_interfaces(PT_VMR vmr); static long initialize_dll_interfaces(PT_VMR vmr);
@@ -79,6 +86,8 @@ static long initialize_dll_interfaces(PT_VMR vmr)
if (G_H_Module == NULL) if (G_H_Module == NULL)
return -101; return -101;
PRAGMA_IgnoreWCastIncompatibleFuncTypes;
// Get function pointers // Get function pointers
vmr->VBVMR_Login = (T_VBVMR_Login)GetProcAddress(G_H_Module, "VBVMR_Login"); vmr->VBVMR_Login = (T_VBVMR_Login)GetProcAddress(G_H_Module, "VBVMR_Login");
vmr->VBVMR_Logout = (T_VBVMR_Logout)GetProcAddress(G_H_Module, "VBVMR_Logout"); vmr->VBVMR_Logout = (T_VBVMR_Logout)GetProcAddress(G_H_Module, "VBVMR_Logout");
@@ -110,6 +119,8 @@ static long initialize_dll_interfaces(PT_VMR vmr)
vmr->VBVMR_MacroButton_GetStatus = (T_VBVMR_MacroButton_GetStatus)GetProcAddress(G_H_Module, "VBVMR_MacroButton_GetStatus"); vmr->VBVMR_MacroButton_GetStatus = (T_VBVMR_MacroButton_GetStatus)GetProcAddress(G_H_Module, "VBVMR_MacroButton_GetStatus");
vmr->VBVMR_MacroButton_SetStatus = (T_VBVMR_MacroButton_SetStatus)GetProcAddress(G_H_Module, "VBVMR_MacroButton_SetStatus"); vmr->VBVMR_MacroButton_SetStatus = (T_VBVMR_MacroButton_SetStatus)GetProcAddress(G_H_Module, "VBVMR_MacroButton_SetStatus");
PRAGMA_Pop;
// check pointers are valid // check pointers are valid
if (vmr->VBVMR_Login == NULL) if (vmr->VBVMR_Login == NULL)
return -1; return -1;

View File

@@ -126,14 +126,14 @@ int main(int argc, char *argv[])
vflag = true; vflag = true;
break; break;
case '?': case '?':
log_warn("unknown option -- '%c'\n" log_fatal("unknown option -- '%c'\n"
"Try .\\vmrcli.exe -h for more information.", "Try .\\vmrcli.exe -h for more information.",
optopt); optopt);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
case ':': case ':':
log_warn("missing argument for option -- '%c'\n" log_fatal("missing argument for option -- '%c'\n"
"Try .\\vmrcli.exe -h for more information.", "Try .\\vmrcli.exe -h for more information.",
optopt); optopt);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
case 'h': case 'h':
[[fallthrough]]; [[fallthrough]];
@@ -144,7 +144,7 @@ int main(int argc, char *argv[])
PT_VMR vmr = create_interface(); PT_VMR vmr = create_interface();
int rep = login(vmr, kind); long rep = login(vmr, kind);
if (rep != 0) if (rep != 0)
{ {
log_fatal("Error logging into the Voicemeeter API"); log_fatal("Error logging into the Voicemeeter API");
@@ -185,15 +185,15 @@ int main(int argc, char *argv[])
} }
rep = logout(vmr); rep = logout(vmr);
if (rep == 0) if (rep != 0)
{
return EXIT_SUCCESS;
}
else
{ {
log_fatal("Error logging out of the Voicemeeter API"); log_fatal("Error logging out of the Voicemeeter API");
return EXIT_FAILURE; return EXIT_FAILURE;
} }
else
{
return EXIT_SUCCESS;
}
} }
/** /**

View File

@@ -30,7 +30,7 @@
*/ */
long login(PT_VMR vmr, int kind) long login(PT_VMR vmr, int kind)
{ {
int rep; long rep;
long v; long v;
log_trace("VBVMR_Login()"); log_trace("VBVMR_Login()");
@@ -75,7 +75,7 @@ long login(PT_VMR vmr, int kind)
*/ */
long logout(PT_VMR vmr) long logout(PT_VMR vmr)
{ {
int rep; long rep;
Sleep(20); /* give time for last command */ Sleep(20); /* give time for last command */
log_trace("VBVMR_Logout()"); log_trace("VBVMR_Logout()");