[Solved] Same C code, different result on x86 and ARM


Linux-SWAT

Forum Addict!
Joined
Feb 13, 2010
Messages
9,188
Hi,

this is a Sobel filter.
It compiles on x86_64 and ARM 32 and 64, and must be used with a 8bit grayscale .bmp .

The problem is that the execution on ARM 32 and 64 produces a garbage image, and I have absolutely no idea why.

I tried GCC 5 and 7 on ARM64.

Any thoughts ?
 

Attachments

  • sobel.zip
    1.9 KB · Views: 423
I didn't test the code, but to me it looks like the unaligned memory access you do with the short pointers may be the culprit. You can get away with that on x86, but not ARM iirc.
 
Maybe it's just the structure that need packing.
try to add
Code:
#pragma pack(push, 1)
befor the definition of the struct in the .h
and
Code:
#pragma pack(pop)
aftrer the definition
 
Back
Top