Adding variable to ToolSettings struct in DNA_scene_types.h breaks compile

I have been trying to trace where the alignment issue is, but have failed. Help / guides appreciated. I am trying to make snapping to be editor dependent, but the more I look at it the more I feel like this might be something too much for me to handle.

[ 65%] Building CXX object source/blender/nodes/CMakeFiles/bf_nodes.dir/intern/node_multi_function.cc.o
[ 65%] Building CXX object source/blender/nodes/CMakeFiles/bf_nodes.dir/intern/node_socket.cc.o
[ 65%] Building CXX object source/blender/nodes/CMakeFiles/bf_nodes.dir/intern/node_socket_declarations.cc.o
[ 65%] Building CXX object source/blender/nodes/CMakeFiles/bf_nodes.dir/intern/node_tree_ref.cc.o
[ 65%] Building C object source/blender/nodes/CMakeFiles/bf_nodes.dir/intern/node_util.c.o
[ 65%] Linking CXX static library ../../../lib/libbf_nodes.a
[ 65%] Built target bf_nodes
[ 65%] Linking CXX static library ../../../../lib/libbf_nodes_geometry.a
[ 65%] Built target bf_nodes_geometry
make[1]: *** [Makefile:163: all] Error 2
make: *** [GNUmakefile:347: all] Error 2

Look at the whole build log not just the tail end since it doens’t have the actual error.

Edit: Now that I see the error, I might have found my answer? How to do proper alignment in structs?

log_file.txt (45.2 KB)

This appears to be the location of the issue.

[ 52%] Building CXX object extern/audaspace/CMakeFiles/audaspace-py.dir/bindings/python/PyDevice.cpp.o
[ 52%] Built target buildinfo
[ 52%] Building CXX object extern/audaspace/CMakeFiles/audaspace-py.dir/bindings/python/PyDynamicMusic.cpp.o
Align 2 error (32 bit) in struct: ToolSettings sculpt_paint_settings (add 1 padding bytes)
Align 2 error (64 bit) in struct: ToolSettings sculpt_paint_settings (add 1 padding bytes)
Align 4 error (32 bit) in struct: ToolSettings sculpt_paint_unified_size (add 1 padding bytes)
Align 4 error (64 bit) in struct: ToolSettings sculpt_paint_unified_size (add 1 padding bytes)
Align 4 error (32 bit) in struct: ToolSettings sculpt_paint_unified_unprojected_radius (add 1 padding bytes)
Align 4 error (64 bit) in struct: ToolSettings sculpt_paint_unified_unprojected_radius (add 1 padding bytes)
Align 4 error (32 bit) in struct: ToolSettings sculpt_paint_unified_alpha (add 1 padding bytes)
Align 4 error (64 bit) in struct: ToolSettings sculpt_paint_unified_alpha (add 1 padding bytes)
Align struct error: ToolSettings unified_paint_settings
Align 4 error (32 bit) in struct: ToolSettings unified_paint_settings (add 1 padding bytes)
Align 4 error (64 bit) in struct: ToolSettings unified_paint_settings (add 1 padding bytes)
Align struct error: ToolSettings curve_paint_settings
Align 4 error (32 bit) in struct: ToolSettings curve_paint_settings (add 1 padding bytes)
Align 4 error (64 bit) in struct: ToolSettings curve_paint_settings (add 1 padding bytes)
Align struct error: ToolSettings statvis
Align 4 error (32 bit) in struct: ToolSettings statvis (add 1 padding bytes)
Align 4 error (64 bit) in struct: ToolSettings statvis (add 1 padding bytes)
Align 4 error (32 bit) in struct: ToolSettings normal_vector[3] (add 1 padding bytes)
Align 4 error (64 bit) in struct: ToolSettings normal_vector[3] (add 1 padding bytes)
Align pointer error in struct (size_native 8): ToolSettings *custom_bevel_profile_preset
Align pointer error in struct (size_64 8): ToolSettings *custom_bevel_profile_preset
Align pointer error in struct (size_native 8): ToolSettings *sequencer_tool_settings
Align pointer error in struct (size_64 8): ToolSettings *sequencer_tool_settings
Sizeerror in 32 bit struct: ToolSettings (add 3 bytes)
Sizeerror in 64 bit struct: ToolSettings (add 7 bytes)
Sizeerror 4 in struct: ToolSettings (add 1 bytes)
make[3]: *** [source/blender/makesdna/intern/CMakeFiles/bf_dna.dir/build.make:62: source/blender/makesdna/intern/dna.c] Error 1
make[3]: *** Deleting file 'source/blender/makesdna/intern/dna.c'
[ 52%] Generating operations/COM_OpenCLKernels.cl.h
make[2]: *** [CMakeFiles/Makefile2:7072: source/blender/makesdna/intern/CMakeFiles/bf_dna.dir/all] Error 2
make[2]: *** Waiting for unfinished jobs....

Blender successfully built :slight_smile:

Thanks for the help (here and the other thread).

1 Like

Allright, of all those errors, ignore all but the first one, and add a 1 byte padding field before sculpt_paint_settings in the ToolSettings struct. then build again.

edit: oh you got it already! splendid !

1 Like

Just for completeness if someone looking for an answer, I had to add 7 bytes (same as in the other thread oddly)

  /* UV painting */
  char _pad2[1];
  char uv_sculpt_settings;
  char uv_relax_method;
  /* XXX: these sculpt_paint_* fields are deprecated, use the
   * unified_paint_settings field instead! */
  char _pad7[7];
  short sculpt_paint_settings DNA_DEPRECATED;

DNA_scene_types.txt (66.0 KB)