Andrey Epifantsev
Andrey Epifantsev

Reputation: 1104

C++ find all pointer arithmetic in file

There are several large C++ source files. We need to find all pointer arithmetic operations in these files. Is it possible to do this task automatically?

Is it possible to disable pointer arithmetic in some compiler and get list of errors?

Upvotes: 1

Views: 248

Answers (2)

brian beuning
brian beuning

Reputation: 2862

Make a copy of your code and change all pointer variables to (void *). Then all pointer arithmetic will get compile errors.

Upvotes: 3

Jonathan Wood
Jonathan Wood

Reputation: 67345

The short answer is "no".

However, if you had software that could fully parse and understand your source code, that software would be able to determine this information. This is a major undertaking if you were to write such software yourself.

Upvotes: 0

Related Questions