Windows build fix after r36071
authoraroben@apple.com <aroben@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 4 Sep 2008 16:09:53 +0000 (16:09 +0000)
committeraroben@apple.com <aroben@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 4 Sep 2008 16:09:53 +0000 (16:09 +0000)
        We were getting these errors:

        error C2356: initialization segment must not change during translation
        unit

        This was happening because multiple files #included by
        DerivedSources.cpp were themselves #including StaticConstructors.h. I
        fixed the error by adding header guards to StaticConstructors.h so its
        contents will only be included once.

        But it's also not a good idea for StaticConstructors.h to end up in
        DerivedSources.cpp, since it ends up "polluting" all the source files
        we have in there. So I removed all the files that include
        StaticConstructors.h and added some preprocessor directives to
        DerivedSources.cpp to catch this error in the future.

        * DerivedSources.cpp: Removed the *Names.cpp files, which include
        StaticConstructors.h, and added some preprocessor directives to make
        sure we don't end up accidentally including StaticConstructors.h in
        the future.
        * WebCore.vcproj/WebCore.vcproj: Added the *Names.cpp files.
        * platform/StaticConstructors.h: Added header guards.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@36091 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog
WebCore/DerivedSources.cpp
WebCore/WebCore.vcproj/WebCore.vcproj
WebCore/platform/StaticConstructors.h

index 3dcf213..62124a9 100644 (file)
@@ -1,5 +1,32 @@
 2008-09-04  Adam Roben  <aroben@apple.com>
 
 2008-09-04  Adam Roben  <aroben@apple.com>
 
+        Windows build fix after r36071
+
+        We were getting these errors:
+
+        error C2356: initialization segment must not change during translation
+        unit
+
+        This was happening because multiple files #included by
+        DerivedSources.cpp were themselves #including StaticConstructors.h. I
+        fixed the error by adding header guards to StaticConstructors.h so its
+        contents will only be included once.
+
+        But it's also not a good idea for StaticConstructors.h to end up in
+        DerivedSources.cpp, since it ends up "polluting" all the source files
+        we have in there. So I removed all the files that include
+        StaticConstructors.h and added some preprocessor directives to
+        DerivedSources.cpp to catch this error in the future.
+
+        * DerivedSources.cpp: Removed the *Names.cpp files, which include
+        StaticConstructors.h, and added some preprocessor directives to make
+        sure we don't end up accidentally including StaticConstructors.h in
+        the future.
+        * WebCore.vcproj/WebCore.vcproj: Added the *Names.cpp files.
+        * platform/StaticConstructors.h: Added header guards.
+
+2008-09-04  Adam Roben  <aroben@apple.com>
+
         Windows build fix
 
         * platform/graphics/win/FontPlatformData.h: Added a missing #include
         Windows build fix
 
         * platform/graphics/win/FontPlatformData.h: Added a missing #include
index 8211465..b8b9529 100644 (file)
@@ -25,7 +25,6 @@
 
 // This all-in-one cpp file cuts down on template bloat to allow us to build our Windows release build.
 
 
 // This all-in-one cpp file cuts down on template bloat to allow us to build our Windows release build.
 
-#include "HTMLNames.cpp"
 #include "JSAttr.cpp"
 #include "JSBarInfo.cpp"
 #include "JSCanvasGradient.cpp"
 #include "JSAttr.cpp"
 #include "JSBarInfo.cpp"
 #include "JSCanvasGradient.cpp"
 #include "JSXPathResult.cpp"
 #include "JSXSLTProcessor.cpp"
 #include "SVGElementFactory.cpp"
 #include "JSXPathResult.cpp"
 #include "JSXSLTProcessor.cpp"
 #include "SVGElementFactory.cpp"
-#include "SVGNames.cpp"
 #include "UserAgentStyleSheetsData.cpp"
 #include "UserAgentStyleSheetsData.cpp"
-#include "XLinkNames.cpp"
-#include "XMLNames.cpp"
+
+// On MSVC, including StaticConstructors.h causes all global objects not to be
+// automatically initialized by the C runtime. This is useful in some specific
+// cases (e.g., the *Names.cpp files), but can be dangerous in others. We don't
+// want StaticConstructors.h to "pollute" all the source files we #include here
+// accidentally, so we'll throw an error whenever any file includes it.
+#ifdef StaticConstructors_h
+#error Don't include any file in DerivedSources.cpp that includes StaticConstructors.h
+#endif
index e07c6d3..d6caa42 100644 (file)
                                </FileConfiguration>\r
                        </File>\r
                        <File\r
                                </FileConfiguration>\r
                        </File>\r
                        <File\r
+                               RelativePath="$(WebKitOutputDir)\obj\$(ProjectName)\DerivedSources\HTMLNames.cpp"\r
+                               >\r
+                       </File>\r
+                       <File\r
                                RelativePath="$(WebKitOutputDir)\obj\$(ProjectName)\DerivedSources\HTMLNames.h"\r
                                >\r
                        </File>\r
                                RelativePath="$(WebKitOutputDir)\obj\$(ProjectName)\DerivedSources\HTMLNames.h"\r
                                >\r
                        </File>\r
                                >\r
                        </File>\r
                        <File\r
                                >\r
                        </File>\r
                        <File\r
+                               RelativePath="$(WebKitOutputDir)\obj\$(ProjectName)\DerivedSources\SVGNames.cpp"\r
+                               >\r
+                       </File>\r
+                       <File\r
                                RelativePath="$(WebKitOutputDir)\obj\$(ProjectName)\DerivedSources\SVGNames.h"\r
                                >\r
                        </File>\r
                                RelativePath="$(WebKitOutputDir)\obj\$(ProjectName)\DerivedSources\SVGNames.h"\r
                                >\r
                        </File>\r
                                >\r
                        </File>\r
                        <File\r
                                >\r
                        </File>\r
                        <File\r
+                               RelativePath="$(WebKitOutputDir)\obj\$(ProjectName)\DerivedSources\XLinkNames.cpp"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="$(WebKitOutputDir)\obj\$(ProjectName)\DerivedSources\XMLNames.cpp"\r
+                               >\r
+                       </File>\r
+                       <File\r
                                RelativePath="$(WebKitOutputDir)\obj\$(ProjectName)\DerivedSources\XMLNames.h"\r
                                >\r
                        </File>\r
                                RelativePath="$(WebKitOutputDir)\obj\$(ProjectName)\DerivedSources\XMLNames.h"\r
                                >\r
                        </File>\r
index 5fdc7c1..26b44de 100644 (file)
@@ -20,6 +20,9 @@
  *
  */
 
  *
  */
 
+#ifndef StaticConstructors_h
+#define StaticConstructors_h
+
 // For WebCore we need to avoid having static constructors. We achieve this
 // with two separate methods for GCC and MSVC. Both methods prevent the static
 // initializers from being registered and called on program startup. On GCC, we
 // For WebCore we need to avoid having static constructors. We achieve this
 // with two separate methods for GCC and MSVC. Both methods prevent the static
 // initializers from being registered and called on program startup. On GCC, we
@@ -69,3 +72,5 @@
     void * name[(sizeof(type) + sizeof(void *) - 1) / sizeof(void *)];
 #endif
 #endif
     void * name[(sizeof(type) + sizeof(void *) - 1) / sizeof(void *)];
 #endif
 #endif
+
+#endif // StaticConstructors_h