labyrinth
labyrinth

Reputation: 1164

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?

Upvotes: 1

Views: 51

Answers (1)

alk
alk

Reputation: 70951

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.

Upvotes: 2

Related Questions