Cleanup: Fix one-definition-rule violations for various structs
This fixes most "One Definition Rule" violations inside blender proper resulting from duplicate structures of the same name. The fixes were made similar to that of !135491. See also #120444 for how this has come up in the past. These were found by using the following compile options: -flto=4 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing Note: There are still various ODR issues remaining that require more / different fixes than what was done here. Pull Request: https://projects.blender.org/blender/blender/pulls/136371
This commit is contained in:
committed by
Jesse Yurkovich
parent
6935ec2fa7
commit
f60c528c48
@@ -107,6 +107,8 @@ typedef struct localListBase {
|
||||
void *first, *last;
|
||||
} localListBase;
|
||||
|
||||
namespace {
|
||||
|
||||
/* NOTE(@hos): keep this struct aligned (e.g., IRIX/GCC). */
|
||||
typedef struct MemHead {
|
||||
int tag1;
|
||||
@@ -137,6 +139,8 @@ static_assert(MEM_MIN_CPP_ALIGNMENT <= sizeof(MemHead), "Bad size of MemHead");
|
||||
|
||||
typedef MemHead MemHeadAligned;
|
||||
|
||||
} // namespace
|
||||
|
||||
/* #MemHead::flag. */
|
||||
enum MemHeadFlag {
|
||||
/**
|
||||
|
||||
@@ -31,6 +31,8 @@
|
||||
|
||||
using namespace mem_guarded::internal;
|
||||
|
||||
namespace {
|
||||
|
||||
typedef struct MemHead {
|
||||
/* Length of allocated memory block. */
|
||||
size_t len;
|
||||
@@ -45,6 +47,8 @@ typedef struct MemHeadAligned {
|
||||
static_assert(MEM_MIN_CPP_ALIGNMENT <= alignof(MemHeadAligned), "Bad alignment of MemHeadAligned");
|
||||
static_assert(MEM_MIN_CPP_ALIGNMENT <= sizeof(MemHeadAligned), "Bad size of MemHeadAligned");
|
||||
|
||||
} // namespace
|
||||
|
||||
static bool malloc_debug_memset = false;
|
||||
|
||||
static void (*error_callback)(const char *) = nullptr;
|
||||
|
||||
@@ -465,11 +465,15 @@ static void get_proxy_filepath(const MovieClip *clip,
|
||||
|
||||
#ifdef WITH_OPENEXR
|
||||
|
||||
namespace {
|
||||
|
||||
struct MultilayerConvertContext {
|
||||
float *combined_pass;
|
||||
int num_combined_channels;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
static void *movieclip_convert_multilayer_add_view(void * /*ctx_v*/, const char * /*view_name*/)
|
||||
{
|
||||
return nullptr;
|
||||
|
||||
@@ -274,6 +274,8 @@ static void direction_to_equirect(float r[2], const float dir[3])
|
||||
r[1] = (acosf(dir[2] / 1.0) - M_PI) / -M_PI;
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
struct MultilayerConvertContext {
|
||||
int num_diffuse_channels;
|
||||
float *diffuse_pass;
|
||||
@@ -281,6 +283,8 @@ struct MultilayerConvertContext {
|
||||
float *specular_pass;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
static void *studiolight_multilayer_addview(void * /*base*/, const char * /*view_name*/)
|
||||
{
|
||||
return nullptr;
|
||||
|
||||
@@ -65,6 +65,8 @@
|
||||
# include "BLI_time_utildefines.h"
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
|
||||
using eSign = int8_t;
|
||||
|
||||
#ifdef USE_KDTREE
|
||||
@@ -147,6 +149,8 @@ struct PolyFill {
|
||||
#endif
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
/* Based on LIBGDX 2013-11-28, APACHE 2.0 licensed. */
|
||||
|
||||
static void pf_coord_sign_calc(const PolyFill *pf, PolyIndex *pi);
|
||||
|
||||
@@ -34,6 +34,8 @@
|
||||
|
||||
#include "BLI_strict_flags.h" /* IWYU pragma: keep. Keep last. */
|
||||
|
||||
namespace {
|
||||
|
||||
/* local types */
|
||||
struct PolyFill {
|
||||
uint edges, verts;
|
||||
@@ -47,6 +49,8 @@ struct ScanFillVertLink {
|
||||
ScanFillEdge *edge_first, *edge_last;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
/* Local functions. */
|
||||
|
||||
#define SF_EPSILON 0.00003f
|
||||
|
||||
@@ -268,6 +268,9 @@ static void bm_edge_to_quad_verts(const BMEdge *e, const BMVert *r_v_quad[4])
|
||||
* \{ */
|
||||
|
||||
/** Cache custom-data delimiters. */
|
||||
|
||||
namespace {
|
||||
|
||||
struct DelimitData_CD {
|
||||
int cd_type;
|
||||
int cd_size;
|
||||
@@ -291,6 +294,8 @@ struct DelimitData {
|
||||
int cdata_len;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
/** Determines if the loop custom-data is contiguous. */
|
||||
static bool bm_edge_is_contiguous_loop_cd_all(const BMEdge *e, const DelimitData_CD *delimit_data)
|
||||
{
|
||||
|
||||
@@ -25,7 +25,16 @@
|
||||
|
||||
#define COST_INVALID FLT_MAX
|
||||
|
||||
struct DelimitData;
|
||||
namespace {
|
||||
|
||||
struct DelimitData {
|
||||
int cd_loop_type;
|
||||
int cd_loop_size;
|
||||
int cd_loop_offset;
|
||||
int cd_loop_offset_end;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
static bool bm_edge_is_delimiter(const BMEdge *e,
|
||||
const BMO_Delimit delimit,
|
||||
@@ -64,13 +73,6 @@ static float bm_vert_edge_face_angle(BMVert *v,
|
||||
#undef ANGLE_TO_UNIT
|
||||
}
|
||||
|
||||
struct DelimitData {
|
||||
int cd_loop_type;
|
||||
int cd_loop_size;
|
||||
int cd_loop_offset;
|
||||
int cd_loop_offset_end;
|
||||
};
|
||||
|
||||
static bool bm_edge_is_contiguous_loop_cd_all(const BMEdge *e, const DelimitData *delimit_data)
|
||||
{
|
||||
int cd_loop_offset;
|
||||
|
||||
@@ -46,6 +46,8 @@ static CLG_LogRef LOG = {"ed.undo.curve"};
|
||||
/** \name Undo Conversion
|
||||
* \{ */
|
||||
|
||||
namespace {
|
||||
|
||||
struct UndoCurve {
|
||||
ListBase nubase;
|
||||
int actvert;
|
||||
@@ -72,6 +74,8 @@ struct UndoCurve {
|
||||
size_t undo_size;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
static void undocurve_to_editcurve(Main *bmain, UndoCurve *ucu, Curve *cu, short *r_shapenr)
|
||||
{
|
||||
ListBase *undobase = &ucu->nubase;
|
||||
|
||||
@@ -992,6 +992,8 @@ static int gizmo_cage2d_test_select(bContext *C, wmGizmo *gz, const int mval[2])
|
||||
return -1;
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
struct RectTransformInteraction {
|
||||
float orig_mouse[2];
|
||||
float orig_matrix_offset[4][4];
|
||||
@@ -1000,6 +1002,8 @@ struct RectTransformInteraction {
|
||||
bool use_temp_uniform;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
static int gizmo_cage2d_transform_flag_get(const wmGizmo *gz)
|
||||
{
|
||||
RectTransformInteraction *data = static_cast<RectTransformInteraction *>(gz->interaction_data);
|
||||
|
||||
@@ -429,12 +429,16 @@ static int gizmo_cage3d_get_cursor(wmGizmo *gz)
|
||||
return WM_CURSOR_DEFAULT;
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
struct RectTransformInteraction {
|
||||
float orig_mouse[3];
|
||||
float orig_matrix_offset[4][4];
|
||||
float orig_matrix_final_no_offset[4][4];
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
static void gizmo_cage3d_setup(wmGizmo *gz)
|
||||
{
|
||||
gz->flag |= /* WM_GIZMO_DRAW_MODAL | */ /* TODO */
|
||||
|
||||
@@ -39,6 +39,8 @@
|
||||
/* How much mini buttons offset from the primary. */
|
||||
#define GIZMO_MINI_OFFSET_FAC 0.38f
|
||||
|
||||
namespace {
|
||||
|
||||
enum {
|
||||
GZ_INDEX_MOVE = 0,
|
||||
GZ_INDEX_ZOOM = 1,
|
||||
@@ -52,6 +54,16 @@ struct NavigateGizmoInfo {
|
||||
uint icon;
|
||||
};
|
||||
|
||||
struct NavigateWidgetGroup {
|
||||
wmGizmo *gz_array[GZ_INDEX_TOTAL];
|
||||
/* Store the view state to check for changes. */
|
||||
struct {
|
||||
rcti rect_visible;
|
||||
} state;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
static NavigateGizmoInfo g_navigate_params_for_space_image[GZ_INDEX_TOTAL] = {
|
||||
{
|
||||
"IMAGE_OT_view_pan",
|
||||
@@ -104,14 +116,6 @@ static NavigateGizmoInfo *navigate_params_from_space_type(short space_type)
|
||||
}
|
||||
}
|
||||
|
||||
struct NavigateWidgetGroup {
|
||||
wmGizmo *gz_array[GZ_INDEX_TOTAL];
|
||||
/* Store the view state to check for changes. */
|
||||
struct {
|
||||
rcti rect_visible;
|
||||
} state;
|
||||
};
|
||||
|
||||
static bool WIDGETGROUP_navigate_poll(const bContext *C, wmGizmoGroupType * /*gzgt*/)
|
||||
{
|
||||
if ((U.uiflag & USER_SHOW_GIZMO_NAVIGATE) == 0) {
|
||||
|
||||
@@ -31,12 +31,16 @@
|
||||
/** \name Undo Conversion
|
||||
* \{ */
|
||||
|
||||
namespace {
|
||||
|
||||
struct UndoCurve {
|
||||
PaintCurvePoint *points; /* points of curve */
|
||||
int tot_points;
|
||||
int add_index;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
static void undocurve_from_paintcurve(UndoCurve *uc, const PaintCurve *pc)
|
||||
{
|
||||
BLI_assert(BLI_array_is_zeroed(uc, 1));
|
||||
|
||||
@@ -46,6 +46,8 @@
|
||||
|
||||
#include "UI_view2d.hh"
|
||||
|
||||
namespace {
|
||||
|
||||
enum eBrushUVSculptTool {
|
||||
UV_SCULPT_BRUSH_TYPE_GRAB = 0,
|
||||
UV_SCULPT_BRUSH_TYPE_RELAX = 1,
|
||||
@@ -145,6 +147,8 @@ struct UvSculptData {
|
||||
float uv_base_offset[2];
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
static void apply_sculpt_data_constraints(UvSculptData *sculptdata, float uv[2])
|
||||
{
|
||||
if (!sculptdata->constrain_to_bounds) {
|
||||
|
||||
@@ -363,6 +363,8 @@ void CLIP_OT_reload(wmOperatorType *ot)
|
||||
/** \name View Pan Operator
|
||||
* \{ */
|
||||
|
||||
namespace {
|
||||
|
||||
struct ViewPanData {
|
||||
float x, y;
|
||||
float xof, yof, xorig, yorig;
|
||||
@@ -371,6 +373,8 @@ struct ViewPanData {
|
||||
float *vec;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
static void view_pan_init(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
{
|
||||
wmWindow *win = CTX_wm_window(C);
|
||||
@@ -536,6 +540,8 @@ void CLIP_OT_view_pan(wmOperatorType *ot)
|
||||
/** \name View Zoom Operator
|
||||
* \{ */
|
||||
|
||||
namespace {
|
||||
|
||||
struct ViewZoomData {
|
||||
float x, y;
|
||||
float zoom;
|
||||
@@ -546,6 +552,8 @@ struct ViewZoomData {
|
||||
bool own_cursor;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
static void view_zoom_init(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
{
|
||||
wmWindow *win = CTX_wm_window(C);
|
||||
|
||||
@@ -698,7 +698,6 @@ static void uiblock_layer_pass_buttons(uiLayout *layout,
|
||||
}
|
||||
}
|
||||
|
||||
/* Prevent naming collision. */
|
||||
namespace {
|
||||
|
||||
struct RNAUpdateCb {
|
||||
|
||||
@@ -357,6 +357,8 @@ static bool space_image_main_area_not_uv_brush_poll(bContext *C)
|
||||
/** \name View Pan Operator
|
||||
* \{ */
|
||||
|
||||
namespace {
|
||||
|
||||
struct ViewPanData {
|
||||
float x, y;
|
||||
float xof, yof;
|
||||
@@ -364,6 +366,8 @@ struct ViewPanData {
|
||||
bool own_cursor;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
static void image_view_pan_init(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
{
|
||||
wmWindow *win = CTX_wm_window(C);
|
||||
@@ -504,6 +508,8 @@ void IMAGE_OT_view_pan(wmOperatorType *ot)
|
||||
/** \name View Zoom Operator
|
||||
* \{ */
|
||||
|
||||
namespace {
|
||||
|
||||
struct ViewZoomData {
|
||||
float origx, origy;
|
||||
float zoom;
|
||||
@@ -520,6 +526,8 @@ struct ViewZoomData {
|
||||
ARegion *region;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
static void image_view_zoom_init(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
{
|
||||
wmWindow *win = CTX_wm_window(C);
|
||||
|
||||
@@ -42,6 +42,8 @@
|
||||
/* Margin around the smaller buttons. */
|
||||
#define GIZMO_MINI_OFFSET 2.0f
|
||||
|
||||
namespace {
|
||||
|
||||
enum {
|
||||
GZ_INDEX_MOVE = 0,
|
||||
GZ_INDEX_ROTATE = 1,
|
||||
@@ -68,6 +70,22 @@ struct NavigateGizmoInfo {
|
||||
void (*op_prop_fn)(PointerRNA *ptr);
|
||||
};
|
||||
|
||||
struct NavigateWidgetGroup {
|
||||
wmGizmo *gz_array[GZ_INDEX_TOTAL];
|
||||
/* Store the view state to check for changes. */
|
||||
struct {
|
||||
rcti rect_visible;
|
||||
struct {
|
||||
char is_persp;
|
||||
bool is_camera;
|
||||
char viewlock;
|
||||
char cameralock;
|
||||
} rv3d;
|
||||
} state;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
static void navigate_context_toggle_camera_lock_init(PointerRNA *ptr)
|
||||
{
|
||||
RNA_string_set(ptr, "data_path", "space_data.lock_camera");
|
||||
@@ -130,20 +148,6 @@ static NavigateGizmoInfo g_navigate_params[GZ_INDEX_TOTAL] = {
|
||||
},
|
||||
};
|
||||
|
||||
struct NavigateWidgetGroup {
|
||||
wmGizmo *gz_array[GZ_INDEX_TOTAL];
|
||||
/* Store the view state to check for changes. */
|
||||
struct {
|
||||
rcti rect_visible;
|
||||
struct {
|
||||
char is_persp;
|
||||
bool is_camera;
|
||||
char viewlock;
|
||||
char cameralock;
|
||||
} rv3d;
|
||||
} state;
|
||||
};
|
||||
|
||||
static bool WIDGETGROUP_navigate_poll(const bContext *C, wmGizmoGroupType * /*gzgt*/)
|
||||
{
|
||||
View3D *v3d = CTX_wm_view3d(C);
|
||||
|
||||
@@ -40,6 +40,8 @@ namespace blender::ed::transform {
|
||||
#define STRIP_EDGE_PAN_DELAY 1.0f
|
||||
#define STRIP_EDGE_PAN_ZOOM_INFLUENCE 0.5f
|
||||
|
||||
namespace {
|
||||
|
||||
/** Used for sequencer transform. */
|
||||
struct TransDataSeq {
|
||||
Strip *strip;
|
||||
@@ -68,6 +70,8 @@ struct TransSeq {
|
||||
VectorSet<Strip *> time_dependent_strips;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Sequencer Transform Creation
|
||||
* \{ */
|
||||
|
||||
@@ -31,6 +31,8 @@
|
||||
|
||||
namespace blender::ed::transform {
|
||||
|
||||
namespace {
|
||||
|
||||
/** Used for sequencer transform. */
|
||||
struct TransDataSeq {
|
||||
Strip *strip;
|
||||
@@ -40,6 +42,8 @@ struct TransDataSeq {
|
||||
float orig_rotation;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
static TransData *SeqToTransData(const Scene *scene,
|
||||
Strip *strip,
|
||||
TransData *td,
|
||||
|
||||
@@ -55,6 +55,8 @@ using blender::Vector;
|
||||
/** \name Path Select Struct & Properties
|
||||
* \{ */
|
||||
|
||||
namespace {
|
||||
|
||||
struct PathSelectParams {
|
||||
/** ensure the active element is the last selected item (handy for picking) */
|
||||
bool track_active;
|
||||
@@ -70,6 +72,8 @@ struct UserData_UV {
|
||||
BMUVOffsets offsets;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
static void path_select_properties(wmOperatorType *ot)
|
||||
{
|
||||
RNA_def_boolean(ot->srna,
|
||||
|
||||
@@ -60,6 +60,8 @@ using blender::Vector;
|
||||
|
||||
/* ********************** smart stitch operator *********************** */
|
||||
|
||||
namespace {
|
||||
|
||||
/* object that stores display data for previewing before confirming stitching */
|
||||
struct StitchPreviewer {
|
||||
/* here we'll store the preview triangle indices of the mesh */
|
||||
@@ -231,6 +233,8 @@ struct StitchStateInit {
|
||||
UvElementID *to_select;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
/* constructor */
|
||||
static StitchPreviewer *stitch_preview_init()
|
||||
{
|
||||
|
||||
@@ -49,7 +49,6 @@ enum {
|
||||
LAPDEFORM_SYSTEM_CHANGE_NOT_VALID_GROUP,
|
||||
};
|
||||
|
||||
/* Prevent naming collision. */
|
||||
namespace {
|
||||
|
||||
struct LaplacianSystem {
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
|
||||
#include "eigen_capi.h"
|
||||
|
||||
/* Prevent naming collision. */
|
||||
namespace {
|
||||
|
||||
struct LaplacianSystem {
|
||||
|
||||
Reference in New Issue
Block a user