warning C4251: 'm_ListInfo' : struct 'DuiLib::tagTListInfoUI' needs to have dll-interface to be used

本文介绍了如何在Duilib项目中正确配置DLL接口,确保结构体能够在DLL中正确使用。通过在结构体定义前添加特定宏,可以解决编译警告问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在StdAfx.h中添加以下:

// Duilib使用设置部分

#pragma once

 

#define WIN32_LEAN_AND_MEAN        

#define _CRT_SECURE_NO_DEPRECATE

 

#include <windows.h>

#include <objbase.h>

 

#include "..\DuiLib\UIlib.h"

 

using namespace DuiLib;

 

#ifdef _DEBUG

#   ifdef _UNICODE

#       pragma comment(lib, "..\\bin\\DuiLib_ud.lib")

#   else

#       pragma comment(lib, "..\\bin\\DuiLib_d.lib")

#   endif

#else

#   ifdef _UNICODE

#       pragma comment(lib, "..\\bin\\DuiLib_u.lib")

#   else

#       pragma comment(lib, "..\\bin\\DuiLib.lib")

#   endif

#endif

之后编译一下就会出警告warning C4251: 'm_ListInfo' : struct 'DuiLib::tagTListInfoUI' needs to have dll-interface to be used by clients of class 'DuiLib::CListUI'等。。��?/P>

大概意思是说:结构体tagTListInfoUI被CListUI类使用需要一个dll接口(因为CListUI'被__declspec(dllexport/dllimport))所以也要把结构体也需要__declspec(dllexport/dllimport)),就是在结构体加上导入导出宏UILIB_API。typedef struct  UILIB_API tagTListInfoUI{...}

#ifdef UILIB_EXPORTS
#define UILIB_API __declspec(dllexport)
#else
#define UILIB_API __declspec(dllimport)
#endif

<androidx.constraintlayout.widget.ConstraintLayout android:id="@+id/listinfo" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@drawable/round_style" android:elevation="4dp" android:layout_margin="8dp" android:clickable="true" android:padding="10dp"> <com.xuexiang.xui.widget.textview.autofit.AutoFitTextView android:id="@+id/code" style="@style/item_show_title" android:layout_width="14dp" android:layout_height="16dp" android:paddingTop="2dp" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> <com.xuexiang.xui.widget.textview.autofit.AutoFitTextView style="@style/item_show_title" android:id="@+id/name" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/code"/> <com.xuexiang.xui.widget.textview.autofit.AutoFitTextView style="@style/item_show_title" android:id="@+id/spec" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/name"/> <com.xuexiang.xui.widget.textview.autofit.AutoFitTextView style="@style/item_show_title" android:id="@+id/composition" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/spec"/> <com.xuexiang.xui.widget.textview.autofit.AutoFitTextView style="@style/item_show_title" android:id="@+id/weight" app:layout_constraintStart_toEndOf="@+id/composition" app:layout_constraintTop_toBottomOf="@+id/spec"/> <ImageView android:id="@+id/status" android:layout_width="wrap_content" android:layout_height="wrap_content" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintTop_toBottomOf="@+id/name" app:layout_constraintTop_toTopOf="parent" /> <View style="@style/item_show" android:id="@+id/view_task_list" android:layout_width="match_parent" android:layout_height="1dp" android:background="#cccccc" android:layout_marginTop="3dp" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintTop_toBottomOf="@+id/composition" app:layout_constraintStart_toStartOf="@+id/composition"/> </androidx.constraintlayout.widget.ConstraintLayout>点击表格,显示弹窗展示列内容
06-04
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值