Re: [PD] C externals in M1 give errors

2022-08-16 Thread IOhannes m zmoelnig
On 8/15/22 08:29, Jaime Oliver wrote: The specific error I'm getting right now is that it is reading that number 32 as 29. Again, this same code works fine in all other OSs I've tried. I'm assuming the issue is in the pow() function and all the typecasting (int), (double) as Chris suggested?

Re: [PD] C externals in M1 give errors

2022-08-15 Thread Brad Garton
Christof points out problems with atoi() and line endings -- I ran into similar problems some time ago and resorted to sscanf()-ing what I read from the file to format it it 'properly' in memory before doing the conversion. brad On Mon, Aug 15, 2022 at 3:39 AM Christof Ressi wrote: > Edwin has

Re: [PD] C externals in M1 give errors

2022-08-15 Thread Christof Ressi
Edwin has already pointed out the immediate error in your code. However, there are a lot more problems. First some general issues: * you need to free the line buffer before returning from the function, otherwise there will be a memory leak. * AFAICT, the string buffer passed to atoi() is not

Re: [PD] C externals in M1 give errors

2022-08-14 Thread Edwin van der Heide
pow() must be giving you 9.999 (or something similar) instead of 10 which is rounded down to 9 by the int typecast. This results in 3 * 9 + 2 = 29. To solve this you can, for example, do a round() before the typecast or you can add 0.5 to the output of pow() before doing the typecast. Best!

Re: [PD] C externals in M1 give errors

2022-08-14 Thread Jaime Oliver
Hi Chris, Brad, All, I managed to trace the error to the function below. It reads a text file and copies its contents to a matrix. The file it's reading is always made of lines with the same number of elements like this below: 0 4 4 8 32 1 4 4 8 32 2 4 4 8 32 ... The specific error I'm getting r

Re: [PD] C externals in M1 give errors

2022-08-12 Thread Chris Clepper
That issue only relates to data corruption in the case of major failures like power loss and kernel panics. In most of those situations some data loss is not only expected but also the least of your concerns. As for the original topic, the first thing to check is the usual problems moving between

Re: [PD] C externals in M1 give errors

2022-08-12 Thread Bastiaan van den Berg
Did you read that M1's storage has so much cache + lies to the OS about cache commitments, leading to data corruption sometimes? https://twitter.com/marcan42/status/1494213855387734019 On Fri, Aug 12, 2022 at 6:14 AM Jaime Oliver wrote: > Dear all, > > I have a c external that compiles and runs

[PD] C externals in M1 give errors

2022-08-11 Thread Jaime Oliver
Dear all, I have a c external that compiles and runs fine on windows, Linux, and Mac Intel systems, but while the exact same code compiles ok on a Mac M1 system, it runs with errors. I am trying to figure out the bug, but wonder if anyone has come across something like this? The external itself i