Another idea would be to run both files through B::Deparse.
in reply to How to know if two files (.c,.h,.cpp) are different content-wise ignoring the comments?
That would standardise whitespace, get rid of comments and standardise code structures, too. Perhaps overkill, but it's probably the only way to tell if two files are compiled identically.
Edit: I just saw you mention .cpp, i.e. this is not about perl code, so B::Deparse won't work. The problem I can see with just stripping comments and comparing the files is that even if you strip empty lines, they may have different whitespace within lines that's not relevant to the code but would be picked up by tools like diff.