- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
1)我目前正在尝试理解以下代码,但我无法理解 void(*func)(void) 的含义,我可以理解我正在尝试保存名为“function”的函数的地址来自 list0513,在 void 指针函数处,但是等号之前的转换 (void) 意味着什么?
// list0513.c
#include <dlfcn.h>
int main(void)
{
void *handle = dlopen("./list0513.so", RTLD_LAZY);
void (*func)(void) = dlsym(handle, "function");
(*func)();
dlclose (handle);
return 0;
}
根据书中所述,名为“function”的函数是从以下脚本中调用的
// list0513dl.c
#include <stdio.h>
void function(void)
{
printf("Hello World\n");
}
2) 但是如何制作 list0513.so 文件呢?我制作的唯一文件是 .c 文件...感谢您阅读本文。
最佳答案
声明内容如下:
func — func
*func — is a pointer to
(*func)( ) — a function taking
(*func)(void) — no parameters
void (*func)(void) — returning void
然后使用dlsym
调用的结果初始化func
指针,该结果返回函数“function
”的地址库list0513.so
。
指针类型的一般声明规则:
T *p; // p is a pointer to T
T *p[N]; // p is an array of pointer to T
T (*p)[N]; // p is a pointer to an array of T
T *f(); // f is a function returning a pointer to T
T (*f)(); // f is a pointer to a function returning T
在声明和表达式中,后缀[]
下标和()
函数调用运算符的优先级高于一元*
,因此*f()
被解析为 *(f())
(函数返回指针)。要声明指向数组或函数的指针,*
必须与数组或函数声明符显式分组。
声明可能会变得相当复杂 - 你可以有一个指向函数的指针数组:
T (*a[N])(); // a is an array of pointers to functions returning T
或返回数组指针的函数:
T (*f())[N]; // f is a function returning a pointer to an array
甚至是指向返回数组指针的函数的指针数组的指针:
T (*(*(*a)[N])())[M];
不过,你可能不会在野外看到任何毛茸茸的东西(除非你遇到我的一些旧代码)。
关于c - "(datatype) (*ptrname) (datatype)"是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55074134/
这个问题已经有答案了: EmailAddress or DataType.Email attribute (3 个回答) 已关闭 3 年前。 我使用了像[EmailAddress]这样的数据属性和[D
我收到此错误: "CS0104: 'DataType' is an ambiguous reference between 'System.ComponentModel.DataAnnotations
1)我目前正在尝试理解以下代码,但我无法理解 void(*func)(void) 的含义,我可以理解我正在尝试保存名为“function”的函数的地址来自 list0513,在 void 指针函数处,
我们可以以某种方式应用这种格式吗? [Display(Name = "Date of Birthday")] [DataType(DataType.Date)] public DateTime DOB
我已按照 ORMLite 文档的规定将我的类型声明为 SERIALIZABLE,但我仍然得到: ORMLite can't store unknown class interface java.io.
嗨。 这就是我想要做的: str2 = "91"; str1 = "19"; var testQuery = from c1 in str1
我在 MVC 5 中使用 ASP.NET 身份。对于密码验证,我在 AccountViewModels.cs 中有以下代码: [Required] [DataType(DataType.Passwor
我试图了解使用之间的主要区别是什么[DataType(DataType.EmailAddress)] & [EmailAddress] . 在模型类中:- public class MYViewMod
使用 DataType Attribute 有什么区别?并传入值 DataType.Phone和 Phone Attribute它继承自 DataType 并自动设置 DataType.Phone?
我的 ViewModel 中有以下字段: [DataType(DataType.Date)] [Display(Name = "Preferred date)")] publi
如果没记错的话,是[DataType(DataType.Currency)]的DataAnnotation的对应部分在 Fluent api 中是 modelBuilder.Entity.Proper
给定一个 pandas.DataFrame带有包含混合数据类型的列,例如 df = pd.DataFrame({'mixed': [pd.Timestamp('2020-10-04'), 999, '
我在电子邮件字段上使用此代码: [Required] [DataType(DataType.EmailAddress)] [Display(Name = "Email addr
我是 NodeJs 开发的新手 我正在使用带有 mysql 和 Sequelize 的 NodeJs 来创建具有这些属性的 Batch 模型。 const Batch = sequelize.defi
我想动态生成我的数据框架构我有以下内容 错误: assert isinstance(dataType, DataType), "dataType should be DataType" Asse
我是 Golang 的新手。抱歉,我仍然对以下两者之间的区别感到困惑: type 和 type = 这是一个例子: package main import "fmt" func main()
当电子邮件地址以数字开头时,DataType DataAnnotation 中 DataType.Email 的内部验证似乎失败了。当具有 1234Something@gmail.com 样式电子邮件
有需求从CSV文件中提取数据,然后将其转换为XML,最终加载到目标中。 CSV文件中的数据为 Number,Email,Email Communication,Member Type,VIN 8532
我正在使用 [DataType(DataType.Date)]关于我们模型中的属性。 如何让 Razor 添加 css 类 datepicker到所有属于 DataType.Date 的文本框特性?
我的表 CalTime 有一个时间数据类型的列 Timespent。它以 HH:MM:SS 格式存储值。请建议如何求和该列的值。 Timespent _______ 00:07:
我是一名优秀的程序员,十分优秀!