Hi Robert,

There is a compiler option /Zp[n] which does the same thing. It
changes alignments of all structures in a module so there will be more
momory allocated at runtime, which is not suggested in the msdn. See
http://msdn.microsoft.com/en-us/library/xh3e3fd0(VS.80).aspx for
details.

The CMakeLists file attached is from the src/osgWrappers/serializers
directory. The added /Zp16 option works fine for current serializers
without warnings. But I'm still not sure if there would be other side
effects besides requiring extra memory spaces. Maybe somebody else
could help us explain the harms of packing structures on high bytes
boundaries, if any?

Regards,

Wang Rui


2010/3/25 Robert Osfield <[email protected]>:
> Hi Wang Rui,
>
> Sorry for the slow reply.  Lack of expertise in the area of VS #pragma
> makes it awkward for me to provide any authoritative view, so I'm in a
> listening and learning mode :-)
>
> I've just reviewed your changes and I feel that the use of push and
> pop isn't something that is prone to errors in maintenance - I see the
> copy and paste anti-pattern strike the OSG code base all too often,
> and coding practices like this raise the stakes.  Adding #if's around
> the pragma would exacerbate this issue, but just upping the number of
> lines of code required just to fix a warning.
>
> Would it be possible to set a compiler flag to set the packing
> setting?  Would setting the packing size to 16 all the serializer
> plugins lead to a significant inflation in memory size of the
> wrappers?  I'm wondering if we can't just add CMake settings to
> address this issue, this way the change would be limited to a line or
> two in the CMakeLists.txt, rather than spread out in source files.
>
> Thoughts?
> Robert.
>
#---------------------------------------------------
# OSG CMAKE SUPPORT
# (C) by Michael Wagner, [email protected] 2005
# (C) Eric Wing, Luigi Calori and Robert Osfield 2006-2007
#---------------------------------------------------

PROJECT(OSG_PLUGINS_MASTER)

IF(NOT DYNAMIC_OPENSCENEGRAPH)
    ADD_DEFINITIONS(-DOSG_LIBRARY_STATIC)
ENDIF()

IF(NOT MSVC)
    SET(LIBRARY_OUTPUT_PATH "${LIBRARY_OUTPUT_PATH}/${OSG_PLUGINS}")
    SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY 
"${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${OSG_PLUGINS}")
ENDIF()

SET(CMAKE_SHARED_MODULE_PREFIX ${OSG_PLUGIN_PREFIX})

IF(MSVC80 OR MSVC90)
    IF(NOT OSG_MSVC_GENERATE_PLUGINS_AND_WRAPPERS_MANIFESTS)
        SET(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} 
/MANIFEST:NO")
    ENDIF()
ENDIF()

IF(MSVC)
    # Avoid C4121 warnings
    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zp16")
ENDIF()

SET(TARGET_DEFAULT_PREFIX "osgdb_serializers_")
SET(TARGET_DEFAULT_LABEL_PREFIX "Plugins osg serializer")
SET(TARGET_COMMON_LIBRARIES
    OpenThreads
    osg
    osgDB
    osgUtil
)

ADD_SUBDIRECTORY(osg)
ADD_SUBDIRECTORY(osgParticle)
ADD_SUBDIRECTORY(osgTerrain)
ADD_SUBDIRECTORY(osgText)
_______________________________________________
osg-submissions mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org

Reply via email to