简体   繁体   中英

Capture implicit type conversion from int to long and vice versa

I have structure that has a 32bit field for item_id. This field has been used in my complete project as a 32bit field directly, for passing to a function or to save value in a temporary variable. I need to now change this var to be 64bit. That would mean tracing all its usage manually and changing at required places. I am afraid this might miss out some places and can lead to unexpected rollovers. Can I use some mechanized way to do this? Even an exhaustive list of where all I need to change would also help. I was thinking on the lines of using some gcc flag to enable warnings/errors for this. Any idea which should flag should use?

Rename item_id to item64_id and recompile.

The compiler will point you to each and every occurence of the old, now invalid name. Inspect and fix each occurence.

Optionally you can rename it back afterwards using your IDE's refactoring feature.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM