EasyClangComplete icon indicating copy to clipboard operation
EasyClangComplete copied to clipboard

How to tell the plugin to do the staic analyzing using 32bit mode?

Open canfoderiskii opened this issue 9 years ago • 12 comments

I am writing the codes for one 32bit platform. But the plugin keeps telling me something like this "cast to uint8_t* from smaller integer type uint32_t." when I do some explicit casting, which is not a problem on my 32bit platform.

How can I prevent this annoying message?

I tried to add argument "-m32" in c_flags, but not works.

Sorry about my poor issue format, sent via my cellphone.

canfoderiskii avatar Mar 31 '17 07:03 canfoderiskii

Hm. Strange. I may look into this at some point. It seems to be valid as pointer on your system should be 32 bit long. On the separate note, are you really sure converting an integer to a pointer is a good thing?

niosus avatar Mar 31 '17 07:03 niosus

@niosus

  1. The software I am using, like OS, sublime and clang are all 64bit. So I think it is pretty normal if clang gives me some warning like that, I guess it thinks I was developing for x64 platform.
  2. The platform I am developing for is an embedded system, it is very commnon doing the casting for address. Besides, a lot of APIs provided by chip company is designed this way in which I have to do lots of casting.

canfoderiskii avatar Mar 31 '17 08:03 canfoderiskii

Ok, makes sense. I will try to research which flag should be added and if it actually works adding it whenever I have the time.

niosus avatar Mar 31 '17 09:03 niosus

@niosus Thank you very much.

canfoderiskii avatar Mar 31 '17 09:03 canfoderiskii

try adding to flags: -target i386-none-linux-gnueabi

simia avatar Apr 04 '17 07:04 simia

@simia thanks. @niosus As I am using Windows, so I tried -target i686-pc-windows-msvc. but it makes my system not responding any more, I can only manually power off and on.

Strange...

canfoderiskii avatar Apr 05 '17 01:04 canfoderiskii

@simia @niosus There is one time that the editor didn't break my system, I found that my original problem still exists.

canfoderiskii avatar Apr 05 '17 01:04 canfoderiskii

That's really odd as -m flag seems to work: https://godbolt.org/g/8DE93n

Are you compiling c or c++?

simia avatar Apr 05 '17 09:04 simia

@simia C code. Maybe using clang as a static analyzing tool needs an argument other than -m32?

canfoderiskii avatar Apr 05 '17 12:04 canfoderiskii

m32 option works fine on my pc but I am running linux not windows. Not sure if there is any difference. (Yellow outline is not from ECC, ECC generates green ones) image

simia avatar Apr 05 '17 14:04 simia

@simia Thank you! Your screenshot reminds me! I used to write "-std=c11 -m32" for the c_flags parameter. I just have to break it up as you did, and it works!

@niosus The problem is solved.

canfoderiskii avatar Apr 06 '17 12:04 canfoderiskii

Great to hear that!

niosus avatar Apr 06 '17 13:04 niosus