I have written same lines of code in both C and C++ build environment of visual studio 2008 but C code's object file size is 5.5kb and C++ code file size is 6.17 kb. Why is this difference?
Following is the code in both environments:
#include <stdio.h>
struct S
{
char c;
};
void func()
{
int i;
int j;
printf("%d", i);
}
int main()
{
struct S s;
return 0;
}
It links different C runtime libraries in each case. Check here for detailed explanation. For instance, libcmt.lib vs libcpmt.lib.
Just because your code has different meaning in C and C++.
main)i the call to printf has
undefined behavior. Both languages
might decide on different strategies
to shoot you.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With