开发者

Global Variable Count

开发者 https://www.devze.com 2022-12-14 12:53 出处:网络
How to count the number开发者_开发技巧 of global variables in C++ with a program that I can run with Grep?A better method is to have your compiler print a map file.Most map files list all the global v

How to count the number开发者_开发技巧 of global variables in C++ with a program that I can run with Grep?


A better method is to have your compiler print a map file. Most map files list all the global variables and their locations. If you're lucky, the map file may even indicate which translation unit the global variable belongs to.


Grep has no knowledge of the syntax or the grammar; it operates on lines. I don't think this is possible.

Here's a snippet of some code I'm working on:

int count;

Can you tell me if it's global?


You might be able to grep something in the artifacts of compilation such as listing files or object files.


Have you considered using something like cflow? You can get the GNU's version of cflow, the output, can then be greppable?

Hope this helps.

0

精彩评论

暂无评论...
验证码 换一张
取 消