Object file size increases in windows! why?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Gobi Sakthivel
    New Member
    • Jan 2013
    • 26

    Object file size increases in windows! why?

    My sample.h is
    Code:
    #include <string>
    namespace xxx
    {
          class abc
          {
               std::string m_name;
    
               public:
                  void initialize();
          };
    };
    My Sample.cpp is
    Code:
    #include <sample.h>
    using namespace xxx;
    
    void abc::initialize()
    {
        m_name = "Siva";
    }

    My Question is when i compile this code in Linux platform Using g++ compiler My sample.o's Size is 1Kb.. But when the same code is compiled in Windows platform using VC++ Compiler , My sample.o's size is 42Kb..Can some of the experts can help me on this, to reduce the size in windows... Is there any proble with '#include <string>' in Windows platform.
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    What were your VC++ project settings? Release build? Optimize on or off? CLR support yes or no? Unicode yes or no? C or C++?
    Favor size over speed?

    etc...

    Comment

    • Gobi Sakthivel
      New Member
      • Jan 2013
      • 26

      #3
      Release Mode , Maximum optimization O2, No CLR Support, No Unicode , and It is C++ code.

      Flags used while compiling /c /W0 /O2 /GX /GR /DVER_7 /D "NDEBUG" /D "_WIN32_"

      Comment

      • weaknessforcats
        Recognized Expert Expert
        • Mar 2007
        • 9214

        #4
        You should be using the /Os switch to favor small code. /O2 maximixes speed which can cause Visual C++ to create inline functions out of functins that don't have the inline qualiier. That will cause bloat.

        Comment

        Working...