views:

87

answers:

6

I have run though a code formatting tool to my c++ files. It is supposed to make only formatting changes. Now when I built my code, I see that size of object file for some source files have changed. Since my files are very big and tool has changed almost every line, I dont know whether it has done something disastrous. Now i am worried to check in this code to repo as it might lead to runtime error due to formatting tool. My question is , will the size of object file be changed , if code formatting is changed.?

+2  A: 

just formatting the code should not change the size of the object file.

SP
+4  A: 

Brief answer is no:)

Miollnyr
unfortunately, it's also wrong.. :) .. or a little too brief.
roe
+3  A: 

I would not check your code into the repo without thoroughly checking it first (review, testing).

Pure formatting changes should not change the object file size, unless you've done a debug build (in which case all bets are off). A release build should be not just the same size, but barring your using __DATE__ and such to insert preprocessor content, it should be byte-for-byte the same as well.

If the "reformatting" tool has actually done some micro-optimizations for you (caching repeated access to invariants in local vars, or undoing your having done that unnecessarily), that might affect the optimization choices the compiler makes, which can have an effect on the object file. But I wouldn't assume that that was the case.

T.J. Crowder
Thanks. I'll see the diff line by line to see why it is changing the size of the object file.
kumar
`__LINE__` macro is a good bet too.
Charles Beattie
+1  A: 

It might if you compile with debugging symbols, as it might have added more line number information. Normally it wouldn't though, as has already been pointed out.

Try comparing object files built without debugging symbols.

roe
I am not using any debugging options :(. So I think I'll have to check the diff line by line and figure out what must've gone wrong. Thanks
kumar
+3  A: 

if ##__LINE__ macro is used might produce longer strings. How different are the sizes?

(this macro is often hides in new and assert messages in debug.)

Charles Beattie
Good point about ##__LINE__ being hidden in assert macros
David Gelhar
exLbefore: 786536 after: 786504
kumar
Unfortunately this is difficult to ascertain as third party header files I have used might have __LINE__ macro. I'll have to do the hard way of verifying the changes
kumar
That kind of line count difference is small how far out are the obj file differences? have you tried a binary compare of these obj files?
Charles Beattie
+1  A: 

Try to find a comparison tool that won't care about the formatting changes (like perhaps "diff--ignore-all-space") and check using that before checking in.

David Gelhar