drowe67 / LPCNet

Experimental Neural Net speech coding for FreeDV
BSD 3-Clause "New" or "Revised" License
68 stars 25 forks source link

[Win32] __cpuid() problem #61

Closed gvanem closed 1 year ago

gvanem commented 1 year ago

Trying to compile main.cpp using clang-cl, yields this error:

main.cpp(271,5): error: no matching function for call to '__cpuid'
    __cpuid(1, eax, ebx, ecx, edx);
    ^~~~~~~
f:\ProgramFiler\LLVM-16.0.0\win64\lib\clang\16\include\intrin.h(60,6): note: candidate function not viable: requires 2 arguments, but 5 were
      provided
void __cpuid(int[4], int);
     ^
1 error generated.

I fixed it by this patch:

--- a/src/main.cpp 2023-09-02 11:02:53
+++ b/src/main.cpp 2023-09-02 12:12:57
@@ -268,7 +268,16 @@
     // cause crashes.
     uint32_t eax, ebx, ecx, edx;
     eax = ebx = ecx = edx = 0;
+#ifdef __GNUC__
     __cpuid(1, eax, ebx, ecx, edx);
+#else
+    int regs[4];
+    __cpuid(regs, 1);
+    eax = regs[0];
+    ebx = regs[1];
+    ecx = regs[2];
+    edx = regs[3];
+#endif

     if (ecx & (1<<27) && ecx & (1<<28)) {
         // CPU supports XSAVE and AVX

But I have to ask; does this project absolutely require MinGW or something? Strange that petty things like this fails in 2023.

gvanem commented 1 year ago

On a 2nd look, I figured this error out; it was a -D__CPUID_H header-guard that had sneaked in! Hence closing.

gvanem commented 1 year ago

There's still issues with this. Hence re-opening.

tmiw commented 1 year ago

I just searched the current repo and I can't find a main.cpp anywhere in it. Can you confirm that this issue wasn't supposed to be submitted to another project instead?

drowe67 commented 1 year ago

Also in general the FreeDV project doesn't support native Windows compilation, only cross compilation on Windows. The path above suggests a Windows machine.

@tmiw - I wonder if we should make this explicit for this repo too? I think it's only noted in the codec2/README.md

Might also be worth noting this repo is not under active development, and possible headed for deprecation.

@gvanem - can you pls explain your use case for this repo?

gvanem commented 1 year ago

Can you confirm that this issue wasn't supposed to be submitted to another project instead?

Yes, brainfart. Closing.