编译PostgreSQL 9.6的C函数时出错

我正在升级到PostgreSQL 9.6并在尝试编译一些C代码时遇到一些错误。 gcc -c -o lib/libhaver.o src/libhaver.c -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector –param=ssp-buffer-size=4 -m64 -mtune=generic -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fPIC -D_GNU_SOURCE -I. -I/usr/pgsql-9.6/include/server -I/usr/pgsql-9.6/include/server/access -I/usr/pgsql-9.6/include/internal -I/usr/include/et -I/usr/include/libxml2 -I/usr/include 这段代码: #include “postgres.h” #include “fmgr.h” #include “catalog/pg_type.h” #include “funcapi.h” #include “utils/guc.h” #include “access/htup.h” #include “utils/array.h” #include “math.h” #ifdef NEWPOSTGRES #include […]

将双数组转换为unsigned short?

Prob = *((unsigned short*)(Prob)); Prob = (unsigned short)(Prob); 这对我不起作用。 如何正确转换?

套接字客户端使用Select

我试图实现一个客户端function,可以使用select()函数建立与多个服务器的连接。 但我不是使用select()函数的专家。 但是,我的客户端可以启用与多个服务器的连接,但它无法从这些多个服务器读取消息。 根据我的以下示例,我将我的客户端连接到两台服务器( 192.168.100.136, 192.168.100.138) 。 与这两台服务器连接后,我的客户端只从一台服务器( 192.168.100.136 )接收消息,而不是从多台服务器接收消息。 我不确定我在示例程序中使用select()函数的方式。 请更正我的示例应用程序以获得所需的o / p ..提前致谢 int main() { int port = 10001 ; char ip[][32] = {“192.168.100.136″,”192.168.100.138”}; int count = 2 ; int ret = clientSelect(ip,port,count); return 0 ; } int clientSelect(char **ipAddr ,int port , int count) { SOCKET max_sd = 0; SOCKET socketId[10] […]

动态生成变量名称

我只想知道当前编程语言中是否有任何方法可以动态生成像数组这样的变量名称,例如。 for(i=1;i<10;i++) { int a i = ; printf(“the value generated in the logic is %d”,a i); } 我知道有一个类似的方式的数组的概念,但我只是想知道这是否存在于任何编程语言中。 提前致谢….

灰度图像转换.img到.ras – 在Windows中的白色和蓝色的灰度等级?! C

我想将.img文件(512字节标题,512×512像素,每像素8位(值:0-255))转换为.ras文件。 为此,我在本文末尾得到了C代码。 我的测试图像(test.img)的输出应该是黑/白图像 – 所以只包含0或255的值。但问题是,当我在Windows中编译C代码(从底部)时,我的结果。 ras文件是白色还是亮蓝色?! 奇怪的是。 当我在Linux中编译C代码时,结果是完全黑/白?! 这怎么来的? 在两个系统中我使用了64位。 所以你可以尝试一下:1。用以下代码编译C代码:gcc -lm img2ras.c -o img2ras 2.通过控制台将.img转换为.ras:img2ras test.img test.ras 3.在gimp中观察.ras文件,XnView或PaintshopPro 你是否有任何线索如何在具有相同版本的gcc 4.8.1的不同操作系统上发生这种尴尬的结果? test.img: http : //www.file-upload.net/download-8629102/test.img.html img2ras.c /* this program accepts an input file (which comes from the image capturing board) and an output file, which must be specified on the command line. The output file […]

使用select()监听多个客户端(TCP)

我开发了(TCP)服务器来监听客户端并与之交互。 现在我正在尝试调整该服务器代码以收听多个客户端。 我想使用select,但我对我发现的一些例子和解释感到困惑。 我一直在阅读: http : //support.sas.com/documentation/onlinedoc/sasc/doc750/html/lr2/select.htm和http://support.sas.com/documentation/onlinedoc/sasc/doc750/html /lr2/select.htm这两个都被推荐给我..:S 第一个网站的例子似乎不太复杂..(虽然仍然不知道如何使其适应我的代码,因为我非常非常非常新的网络等)但我担心我错过了关键方面,因为第二个网站的例子的复杂性。 下面是我的服务器代码的快照,当只监听一个客户端时(包括一些伪代码以最小化不那么重要的东西): int main(int argc, char *argv[]) { int sockfd, newsockfd, portno, clilen; char buffer[3]; struct sockaddr_in serv_addr, cli_addr; int n; if (argc < 2) { fprintf(stderr,"ERROR, no port provided\n"); exit(1); } sockfd = socket(AF_INET, SOCK_STREAM, 0); if (sockfd < 0){error("ERROR opening socket");} bzero((char *) &serv_addr, sizeof(serv_addr)); […]

扫描多个数字而不扫描输入C

我正在尝试扫描4个数字而不按Enter(我希望它在看到有4个数字时结束扫描)。 我正在使用这个方法: printf(“Enter 4 Numbers(with space):\n”); scanf(“%d %d %d %d” , &guess1 , &guess2 , &guess3 , &guess4); 但它需要数字之间的空格并在最后按Enter键。 那么如何让它接收例如:1234(num1 = 1,num2 = 2等等)并结束接收而不按Enter键。

SIGCHLD导致分段错误,而不是进入处理程序

我正在尝试创建一个简单的shell,并添加了使用&在后台运行进程的function。 在我的主要方法中,我基本上有: int main() { if (signal(SIGCHLD, handle) == SIG_ERR) perror(“Cannot catch SIGCHLD”); pid_t child = fork(); if (child == 0) execvp(command, arguments); else { if (background == 1) { printf(“1”); backgroundList(command, child); printf(“2”); } else waitpid(child, NULL, 0); } } 对于我的经纪人,我有: void handle(int s) { printf(“a”); if (signal(SIGCHLD, handle) == SIG_ERR) perror(“Cannot catch SIGCHLD”); […]

分段错误和链接列表的未知问题

所以我正在尝试编写一个机械程序。 程序很长但是这里有导致我问题的函数: recherche_noe和creation_noe 。 不需要打扰其余的。 这是法语所以请耐心lst_noe我的想法是这样的:首先在main我向用户询问lst_noe的noe lst_noe (这是noe列表)。 使用creation_noe他在向用户询问结构信息时做出了这一点。 最后recherche_noe返回我正在寻找的noe 。 所有信息都存储在struct maillage ,你有其他结构。 谢谢您的帮助。 #include #include #include /*==============================================*/ /* Déclaration des structures */ /*==============================================*/ struct matrice { char nom[20]; int n,m; double **tab; struct matrice *next; }; struct element { int num; int n1, n2; double k; struct element *next; }; struct noeud { […]

将c字符串解析为指针数组时出现分段错误

函数makearg应该计算char数组中的单词数,并将每个单词分解为指针数组中自己的位置。 分段错误似乎是strncpy函数的问题。 int makearg(char s[], char ***args); int main(){ char **args = (char**)(malloc(100)); char *str = “ls is a -l file”; int argc; argc = makearg(str, &args); printf(“%d”, argc); printf(“%c”, ‘\0’); int i; for(i = 0; i < argc; i++){ puts(args); printf("%c", '\n'); } return 0; } ///////////////////////////////////////// int makearg(char s[], char ***args){ int argc […]