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

相关文章

Spring事务中@Transactional注解不生效的原因分析与解决

《Spring事务中@Transactional注解不生效的原因分析与解决》在Spring框架中,@Transactional注解是管理数据库事务的核心方式,本文将深入分析事务自调用的底层原理,解释为... 目录1. 引言2. 事务自调用问题重现2.1 示例代码2.2 问题现象3. 为什么事务自调用会失效3

mysql出现ERROR 2003 (HY000): Can‘t connect to MySQL server on ‘localhost‘ (10061)的解决方法

《mysql出现ERROR2003(HY000):Can‘tconnecttoMySQLserveron‘localhost‘(10061)的解决方法》本文主要介绍了mysql出现... 目录前言:第一步:第二步:第三步:总结:前言:当你想通过命令窗口想打开mysql时候发现提http://www.cpp

SpringBoot启动报错的11个高频问题排查与解决终极指南

《SpringBoot启动报错的11个高频问题排查与解决终极指南》这篇文章主要为大家详细介绍了SpringBoot启动报错的11个高频问题的排查与解决,文中的示例代码讲解详细,感兴趣的小伙伴可以了解一... 目录1. 依赖冲突:NoSuchMethodError 的终极解法2. Bean注入失败:No qu

springboot报错Invalid bound statement (not found)的解决

《springboot报错Invalidboundstatement(notfound)的解决》本文主要介绍了springboot报错Invalidboundstatement(not... 目录一. 问题描述二.解决问题三. 添加配置项 四.其他的解决方案4.1 Mapper 接口与 XML 文件不匹配

Python中ModuleNotFoundError: No module named ‘timm’的错误解决

《Python中ModuleNotFoundError:Nomodulenamed‘timm’的错误解决》本文主要介绍了Python中ModuleNotFoundError:Nomodulen... 目录一、引言二、错误原因分析三、解决办法1.安装timm模块2. 检查python环境3. 解决安装路径问题

如何解决mysql出现Incorrect string value for column ‘表项‘ at row 1错误问题

《如何解决mysql出现Incorrectstringvalueforcolumn‘表项‘atrow1错误问题》:本文主要介绍如何解决mysql出现Incorrectstringv... 目录mysql出现Incorrect string value for column ‘表项‘ at row 1错误报错

如何解决Spring MVC中响应乱码问题

《如何解决SpringMVC中响应乱码问题》:本文主要介绍如何解决SpringMVC中响应乱码问题,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录Spring MVC最新响应中乱码解决方式以前的解决办法这是比较通用的一种方法总结Spring MVC最新响应中乱码解

Java报NoClassDefFoundError异常的原因及解决

《Java报NoClassDefFoundError异常的原因及解决》在Java开发过程中,java.lang.NoClassDefFoundError是一个令人头疼的运行时错误,本文将深入探讨这一问... 目录一、问题分析二、报错原因三、解决思路四、常见场景及原因五、深入解决思路六、预http://www

pip无法安装osgeo失败的问题解决

《pip无法安装osgeo失败的问题解决》本文主要介绍了pip无法安装osgeo失败的问题解决,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一... 进入官方提供的扩展包下载网站寻找版本适配的whl文件注意:要选择cp(python版本)和你py

SpringBoot项目启动报错"找不到或无法加载主类"的解决方法

《SpringBoot项目启动报错找不到或无法加载主类的解决方法》在使用IntelliJIDEA开发基于SpringBoot框架的Java程序时,可能会出现找不到或无法加载主类com.example.... 目录一、问题描述二、排查过程三、解决方案一、问题描述在使用 IntelliJ IDEA 开发基于