20240502解决ARM32编译器编译quectel-CM时for循环出错的解决

2024-05-03 19:28

本文主要是介绍20240502解决ARM32编译器编译quectel-CM时for循环出错的解决,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

20240502解决ARM32编译器编译quectel-CM时for循环出错的解决
2024/5/2 17:17


缘起:QMIThread.c:2100:9: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode


1、修改Makefile为ARM32架构:
Z:\quectel-CM\Makefile

ifneq ($(CROSS_COMPILE),)
CROSS-COMPILE:=$(CROSS_COMPILE)
endif
#CROSS-COMPILE:=/workspace/buildroot/buildroot-qemu_mips_malta_defconfig/output/host/usr/bin/mips-buildroot-linux-uclibc-
#CROSS-COMPILE:=/workspace/buildroot/buildroot-qemu_arm_vexpress_defconfig/output/host/usr/bin/arm-buildroot-linux-uclibcgnueabi-
#CROSS-COMPILE:=/workspace/buildroot-git/qemu_mips64_malta/output/host/usr/bin/mips-gnu-linux-
ifeq ($(CC),cc)
CC:=$(CROSS-COMPILE)gcc
endif
LD:=$(CROSS-COMPILE)ld

修改为:

ifneq ($(CROSS_COMPILE),)
CROSS-COMPILE:=$(CROSS_COMPILE)
endif
#CROSS-COMPILE:=/workspace/buildroot/buildroot-qemu_mips_malta_defconfig/output/host/usr/bin/mips-buildroot-linux-uclibc-
#CROSS-COMPILE:=/workspace/buildroot/buildroot-qemu_arm_vexpress_defconfig/output/host/usr/bin/arm-buildroot-linux-uclibcgnueabi-
#CROSS-COMPILE:=/workspace/buildroot-git/qemu_mips64_malta/output/host/usr/bin/mips-gnu-linux-
CROSS-COMPILE:=/opt/FriendlyARM/toolchain/4.9.3/bin/arm-none-linux-gnueabihf-
##ifeq ($(CC),cc)
##CC:=$(CROSS-COMPILE)gcc
##endif
CC:=/opt/FriendlyARM/toolchain/4.9.3/bin/arm-none-linux-gnueabihf-gcc
LD:=$(CROSS-COMPILE)ld


2、
rootroot@rootroot-ThinkBook-16-G5-IRH:~/quectel-CM$ 
rootroot@rootroot-ThinkBook-16-G5-IRH:~/quectel-CM$ make -j8
cd out/; rm -rf *.o libmnl/*.o quectel-CM quectel-qmi-proxy quectel-mbim-proxy quectel-atc-proxy
/opt/FriendlyARM/toolchain/4.9.3/bin/arm-none-linux-gnueabihf-gcc -Wall -Wextra -Werror -O1  quectel-qmi-proxy.c -o out/quectel-qmi-proxy -lpthread -ldl -lrt 
/opt/FriendlyARM/toolchain/4.9.3/bin/arm-none-linux-gnueabihf-gcc -Wall -Wextra -Werror -O1  quectel-mbim-proxy.c -o out/quectel-mbim-proxy -lpthread -ldl -lrt 
/opt/FriendlyARM/toolchain/4.9.3/bin/arm-none-linux-gnueabihf-gcc -Wall -Wextra -Werror -O1  quectel-atc-proxy.c atchannel.c at_tok.c util.c -o out/quectel-atc-proxy -lpthread -ldl -lrt 
/opt/FriendlyARM/toolchain/4.9.3/bin/arm-none-linux-gnueabihf-gcc -Wall -Wextra -Werror -O1  QmiWwanCM.c GobiNetCM.c main.c QCQMUX.c QMIThread.c util.c qmap_bridge_mode.c mbim-cm.c device.c atc.c atchannel.c at_tok.c udhcpc.c -o out/quectel-CM -lpthread -ldl -lrt
QMIThread.c: In function ‘requestGetProfile’:
QMIThread.c:2100:9: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
         for(int i=0; i<profile_num; i++)
         ^
QMIThread.c:2100:9: note: use option -std=c99, -std=gnu99, -std=c11 or -std=gnu11 to compile your code
QMIThread.c:2111:5: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
     for(int i=0; i<profile_num; i++)
     ^
make: *** [Makefile:32: release] Error 1
rootroot@rootroot-ThinkBook-16-G5-IRH:~/quectel-CM$ 

rootroot@rootroot-ThinkBook-16-G5-IRH:~/quectel-CM$ 


Z:\quectel-CM\QMIThread.c

_re_check:
    pRequest = ComposeQMUXMsg(QMUX_TYPE_WDS, QMIWDS_GET_PROFILE_LIST_REQ, WdsGetProfileListReqSend, profile);
    err = QmiThreadSendQMI(pRequest, &pResponse);s_pResponse = malloc(le16_to_cpu(pResponse->QMIHdr.Length) + 1);
    qmi_rsp_check_and_return();
    
    pProfileList = (PQMIWDS_PROFILELIST)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x01);
    uint8 profile_indexs[42] = {0};
    uint8 profile_num = pProfileList->ProfileList[0];
    if(profile_num >= 1)
    {
        uint8 j = 0;
        uint8 k = 2;
        for(int i=0; i<profile_num; i++)
        {
            profile_indexs[j++] = pProfileList->ProfileList[k];
            if(pProfileList->ProfileList[++k] == 0)
                k+=2;
            else
                k+=2+pProfileList->ProfileList[k];
        }
    }
    free(pResponse);
    
    for(int i=0; i<profile_num; i++)
    {
        profile->profile_index = profile_indexs[i];
        
        pRequest = ComposeQMUXMsg(QMUX_TYPE_WDS, QMIWDS_GET_PROFILE_SETTINGS_REQ, WdsGetProfileSettingsReqSend, profile);
        err = QmiThreadSendQMI(pRequest, &pResponse);
        qmi_rsp_check_and_return();
        
        pPdpContext = (PQMIWDS_PDPCONTEXT)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x25);
        if(pPdpContext->pdp_context == profile->pdp)
            break;
        else
            free(pResponse);

        if(i == profile_num-1)
        {
            pRequest = ComposeQMUXMsg(QMUX_TYPE_WDS, QMIWDS_CREATE_PROFILE_REQ, WdsCreateProfileSettingsReqSend, profile);
            err = QmiThreadSendQMI(pRequest, &pResponse);
            qmi_rsp_check_and_return();
            free(pResponse);
            goto _re_check;
        }
    }


修改为:
_re_check:
    pRequest = ComposeQMUXMsg(QMUX_TYPE_WDS, QMIWDS_GET_PROFILE_LIST_REQ, WdsGetProfileListReqSend, profile);
    err = QmiThreadSendQMI(pRequest, &pResponse);s_pResponse = malloc(le16_to_cpu(pResponse->QMIHdr.Length) + 1);
    qmi_rsp_check_and_return();
    
    pProfileList = (PQMIWDS_PROFILELIST)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x01);
    uint8 profile_indexs[42] = {0};
    uint8 profile_num = pProfileList->ProfileList[0];
    if(profile_num >= 1)
    {
        uint8 j = 0;
        uint8 k = 2;
        //for(int i=0; i<profile_num; i++)
        int i;
        for(i=0; i<profile_num; i++)

        {
            profile_indexs[j++] = pProfileList->ProfileList[k];
            if(pProfileList->ProfileList[++k] == 0)
                k+=2;
            else
                k+=2+pProfileList->ProfileList[k];
        }
    }
    free(pResponse);
    
    //for(int i=0; i<profile_num; i++)
    int i;
    for(i=0; i<profile_num; i++)

    {
        profile->profile_index = profile_indexs[i];
        
        pRequest = ComposeQMUXMsg(QMUX_TYPE_WDS, QMIWDS_GET_PROFILE_SETTINGS_REQ, WdsGetProfileSettingsReqSend, profile);
        err = QmiThreadSendQMI(pRequest, &pResponse);
        qmi_rsp_check_and_return();
        
        pPdpContext = (PQMIWDS_PDPCONTEXT)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x25);
        if(pPdpContext->pdp_context == profile->pdp)
            break;
        else
            free(pResponse);

        if(i == profile_num-1)
        {
            pRequest = ComposeQMUXMsg(QMUX_TYPE_WDS, QMIWDS_CREATE_PROFILE_REQ, WdsCreateProfileSettingsReqSend, profile);
            err = QmiThreadSendQMI(pRequest, &pResponse);
            qmi_rsp_check_and_return();
            free(pResponse);
            goto _re_check;
        }
    }


rootroot@rootroot-ThinkBook-16-G5-IRH:~/quectel-CM$ 
rootroot@rootroot-ThinkBook-16-G5-IRH:~/quectel-CM$ make -j8
cd out/; rm -rf *.o libmnl/*.o quectel-CM quectel-qmi-proxy quectel-mbim-proxy quectel-atc-proxy
/opt/FriendlyARM/toolchain/4.9.3/bin/arm-none-linux-gnueabihf-gcc -Wall -Wextra -Werror -O1  quectel-qmi-proxy.c -o out/quectel-qmi-proxy -lpthread -ldl -lrt 
/opt/FriendlyARM/toolchain/4.9.3/bin/arm-none-linux-gnueabihf-gcc -Wall -Wextra -Werror -O1  quectel-mbim-proxy.c -o out/quectel-mbim-proxy -lpthread -ldl -lrt 
/opt/FriendlyARM/toolchain/4.9.3/bin/arm-none-linux-gnueabihf-gcc -Wall -Wextra -Werror -O1  quectel-atc-proxy.c atchannel.c at_tok.c util.c -o out/quectel-atc-proxy -lpthread -ldl -lrt 
/opt/FriendlyARM/toolchain/4.9.3/bin/arm-none-linux-gnueabihf-gcc -Wall -Wextra -Werror -O1  QmiWwanCM.c GobiNetCM.c main.c QCQMUX.c QMIThread.c util.c qmap_bridge_mode.c mbim-cm.c device.c atc.c atchannel.c at_tok.c udhcpc.c -o out/quectel-CM -lpthread -ldl -lrt
rootroot@rootroot-ThinkBook-16-G5-IRH:~/quectel-CM$ 


rootroot@rootroot-ThinkBook-16-G5-IRH:~/quectel-CM$ cd out/
rootroot@rootroot-ThinkBook-16-G5-IRH:~/quectel-CM/out$ ll
total 272
drwxrwxr-x 2 rootroot rootroot   4096 5月   2 16:29 ./
drwxrwxr-x 5 rootroot rootroot   4096 5月   2 16:29 ../
-rwxrwxr-x 1 rootroot rootroot  45844 5月   2 16:29 quectel-atc-proxy*
-rwxrwxr-x 1 rootroot rootroot 183564 5月   2 16:29 quectel-CM*
-rwxrwxr-x 1 rootroot rootroot  16336 5月   2 16:29 quectel-mbim-proxy*
-rwxrwxr-x 1 rootroot rootroot  20296 5月   2 16:29 quectel-qmi-proxy*
rootroot@rootroot-ThinkBook-16-G5-IRH:~/quectel-CM/out$ 
rootroot@rootroot-ThinkBook-16-G5-IRH:~/quectel-CM/out$ file quectel-CM 
quectel-CM: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-armhf.so.3, for GNU/Linux 3.0.8, BuildID[sha1]=df17be612cd8840b562e01885b0a84d9afa96d78, with debug_info, not stripped
rootroot@rootroot-ThinkBook-16-G5-IRH:~/quectel-CM/out$ 


参考资料:
百度:QMIThread.c:2100:9: error: ‘for’ loop initial declarations are only allowe


https://blog.csdn.net/qq_53381910/article/details/131819714
error: ‘for‘ loop initial declarations are only allowed in C99 or C11 mode


https://blog.csdn.net/lei2014lei/article/details/134590485
error: ‘for‘ loop initial declarations are only allowed in C99 or C11 mode


 

这篇关于20240502解决ARM32编译器编译quectel-CM时for循环出错的解决的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/957466

相关文章

IDEA和GIT关于文件中LF和CRLF问题及解决

《IDEA和GIT关于文件中LF和CRLF问题及解决》文章总结:因IDEA默认使用CRLF换行符导致Shell脚本在Linux运行报错,需在编辑器和Git中统一为LF,通过调整Git的core.aut... 目录问题描述问题思考解决过程总结问题描述项目软件安装shell脚本上git仓库管理,但拉取后,上l

解决docker目录内存不足扩容处理方案

《解决docker目录内存不足扩容处理方案》文章介绍了Docker存储目录迁移方法:因系统盘空间不足,需将Docker数据迁移到更大磁盘(如/home/docker),通过修改daemon.json配... 目录1、查看服务器所有磁盘的使用情况2、查看docker镜像和容器存储目录的空间大小3、停止dock

idea npm install很慢问题及解决(nodejs)

《ideanpminstall很慢问题及解决(nodejs)》npm安装速度慢可通过配置国内镜像源(如淘宝)、清理缓存及切换工具解决,建议设置全局镜像(npmconfigsetregistryht... 目录idea npm install很慢(nodejs)配置国内镜像源清理缓存总结idea npm in

pycharm跑python项目易出错的问题总结

《pycharm跑python项目易出错的问题总结》:本文主要介绍pycharm跑python项目易出错问题的相关资料,当你在PyCharm中运行Python程序时遇到报错,可以按照以下步骤进行排... 1. 一定不要在pycharm终端里面创建环境安装别人的项目子模块等,有可能出现的问题就是你不报错都安装

idea突然报错Malformed \uxxxx encoding问题及解决

《idea突然报错Malformeduxxxxencoding问题及解决》Maven项目在切换Git分支时报错,提示project元素为描述符根元素,解决方法:删除Maven仓库中的resolv... 目www.chinasem.cn录问题解决方式总结问题idea 上的 maven China编程项目突然报错,是

在Ubuntu上打不开GitHub的完整解决方法

《在Ubuntu上打不开GitHub的完整解决方法》当你满心欢喜打开Ubuntu准备推送代码时,突然发现终端里的gitpush卡成狗,浏览器里的GitHub页面直接变成Whoathere!警告页面... 目录一、那些年我们遇到的"红色惊叹号"二、三大症状快速诊断症状1:浏览器直接无法访问症状2:终端操作异常

mybatis直接执行完整sql及踩坑解决

《mybatis直接执行完整sql及踩坑解决》MyBatis可通过select标签执行动态SQL,DQL用ListLinkedHashMap接收结果,DML用int处理,注意防御SQL注入,优先使用#... 目录myBATiFBNZQs直接执行完整sql及踩坑select语句采用count、insert、u

MyBatis Plus大数据量查询慢原因分析及解决

《MyBatisPlus大数据量查询慢原因分析及解决》大数据量查询慢常因全表扫描、分页不当、索引缺失、内存占用高及ORM开销,优化措施包括分页查询、流式读取、SQL优化、批处理、多数据源、结果集二次... 目录大数据量查询慢的常见原因优化方案高级方案配置调优监控与诊断总结大数据量查询慢的常见原因MyBAT

MyBatis/MyBatis-Plus同事务循环调用存储过程获取主键重复问题分析及解决

《MyBatis/MyBatis-Plus同事务循环调用存储过程获取主键重复问题分析及解决》MyBatis默认开启一级缓存,同一事务中循环调用查询方法时会重复使用缓存数据,导致获取的序列主键值均为1,... 目录问题原因解决办法如果是存储过程总结问题myBATis有如下代码获取序列作为主键IdMappe

Java中字符编码问题的解决方法详解

《Java中字符编码问题的解决方法详解》在日常Java开发中,字符编码问题是一个非常常见却又特别容易踩坑的地方,这篇文章就带你一步一步看清楚字符编码的来龙去脉,并结合可运行的代码,看看如何在Java项... 目录前言背景:为什么会出现编码问题常见场景分析控制台输出乱码文件读写乱码数据库存取乱码解决方案统一使