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

Linux-SWAT

Hardcore Member
Joined
Feb 13, 2010
Messages
8,274
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

elvissteinjr

Very Active Member
Joined
Jun 19, 2010
Messages
681
Age
23
Location
Germany
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.
 

ptitSeb

Serial Porter
Joined
Aug 15, 2012
Messages
8,530
Age
47
Location
France, near Lyon
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
 
Top