[Android]Android studio编译程序时报错: error: use of undeclared identifier ’free free(t);

本文解决了一个关于Android项目在更新组件后出现的编译错误问题,错误信息为“use of undeclared identifier 'free'”。问题根源在于NDK版本不兼容,通过回滚到旧版NDK成功解决了编译问题。

原文地址:https://blog.youkuaiyun.com/u010005281/article/details/78611389

问题描述:程序之前可以正常运行,后来更新了一系列部件之后编译不通过,报了好几个一样的错误:error: use of undeclared identifier ’free free(t); 网上搜索并没找到Android相关的解决办法;后来被一个老程序猿告知说是因为ndk版本问题,需要做的是替换ndk版本。ndk具体位置通过点击Android studio的File-->Project Structure...-->SDK location查看(Mac中),具体如图:

图片出处来自http://www.jianshu.com/p/b667baf10306;

具体操作如下:

1. 下载ndk打包文件,网址https://developer.android.google.cn/ndk/downloads/older_releases.html,下载后解压;
2. 定位到上图对应文件位置,选择我们下载解压后的老版本NDK路径。

PS:上述问题是我在编译VirtualApp时遇到的。附VirtualApp编译指南:https://blog.youkuaiyun.com/dodod2012/article/details/88104249

Compiling... 实验2.c C:\Users\Administrator\Desktop\数据结构实验报告\test\实验2.c(32) : error C2275: 'Node' : illegal use of this type as an expression C:\Users\Administrator\Desktop\数据结构实验报告\test\实验2.c(8) : see declaration of 'Node' C:\Users\Administrator\Desktop\数据结构实验报告\test\实验2.c(32) : error C2065: 'newNode' : undeclared identifier C:\Users\Administrator\Desktop\数据结构实验报告\test\实验2.c(34) : error C2223: left of '->data' must point to struct/union C:\Users\Administrator\Desktop\数据结构实验报告\test\实验2.c(37) : error C2223: left of '->next' must point to struct/union C:\Users\Administrator\Desktop\数据结构实验报告\test\实验2.c(38) : warning C4047: '=' : 'struct Node *' differs in levels of indirection from 'int ' C:\Users\Administrator\Desktop\数据结构实验报告\test\实验2.c(42) : error C2275: 'Node' : illegal use of this type as an expression C:\Users\Administrator\Desktop\数据结构实验报告\test\实验2.c(8) : see declaration of 'Node' C:\Users\Administrator\Desktop\数据结构实验报告\test\实验2.c(42) : error C2065: 'prev' : undeclared identifier C:\Users\Administrator\Desktop\数据结构实验报告\test\实验2.c(43) : error C2143: syntax error : missing ';' before 'type' C:\Users\Administrator\Desktop\数据结构实验报告\test\实验2.c(43) : error C2143: syntax error : missing ';' before 'type' C:\Users\Administrator\Desktop\数据结构实验报告\test\实验2.c(43) : error C2143: syntax error : missing ')' before 'type' C:\Users\Administrator\Desktop\数据结构实验报告\test\实验2.c(43) : error C2143: syntax error : missing ';' before 'type' C:\Users\Administrator\Desktop\数据结构实验报告\test\实验2.c(43) : error C2065: 'j' : undeclared identifier C:\Users\Administrator\Desktop\数据结构实验报告\test\实验2.c(43) : warning C4047: '!=' : 'int ' differs in levels of indirection from 'void *' C:\Users\Administrator\Desktop\数据结构实验报告\test\实验2.c(43) : error C2059: syntax error : ')' C:\Users\Administrator\Desktop\数据结构实验报告\test\实验2.c(43) : error C2143: syntax error : missing ';' before '{' C:\Users\Administrator\Desktop\数据结构实验报告\test\实验2.c(44) : error C2223: left of '->next' must point to struct/union C:\Users\Administrator\Desktop\数据结构实验报告\test\实验2.c(47) : warning C4047: '==' : 'int ' differs in levels of indirection from 'void *' C:\Users\Administrator\Desktop\数据结构实验报告\test\实验2.c(49) : error C2223: left of '->next' must point to struct/union C:\Users\Administrator\Desktop\数据结构实验报告\test\实验2.c(49) : error C2223: left of '->next' must point to struct/union C:\Users\Administrator\Desktop\数据结构实验报告\test\实验2.c(50) : error C2223: left of '->next' must point to struct/union C:\Users\Administrator\Desktop\数据结构实验报告\test\实验2.c(58) : error C2275: 'Node' : illegal use of this type as an expression C:\Users\Administrator\Desktop\数据结构实验报告\test\实验2.c(8) : see declaration of 'Node' C:\Users\Administrator\Desktop\数据结构实验报告\test\实验2.c(58) : error C2065: 'temp' : undeclared identifier C:\Users\Administrator\Desktop\数据结构实验报告\test\实验2.c(60) : warning C4047: '=' : 'int ' differs in levels of indirection from 'struct Node *' C:\Users\Administrator\Desktop\数据结构实验报告\test\实验2.c(62) : warning C4022: 'free' : pointer mismatch for actual parameter 1 C:\Users\Administrator\Desktop\数据结构实验报告\test\实验2.c(66) : error C2275: 'Node' : illegal use of this type as an expression C:\Users\Administrator\Desktop\数据结构实验报告\test\实验2.c(8) : see declaration of 'Node' C:\Users\Administrator\Desktop\数据结构实验报告\test\实验2.c(67) : error C2143: syntax error : missing ';' before 'type' C:\Users\Administrator\Desktop\数据结构实验报告\test\实验2.c(67) : error C2143: syntax error : missing ';' before 'type' C:\Users\Administrator\Desktop\数据结构实验报告\test\实验2.c(67) : error C2143: syntax error : missing ')' before 'type' C:\Users\Administrator\Desktop\数据结构实验报告\test\实验2.c(67) : error C2143: syntax error : missing ';' before 'type' C:\Users\Administrator\Desktop\数据结构实验报告\test\实验2.c(67) : error C2223: left of '->next' must point to struct/union C:\Users\Administrator\Desktop\数据结构实验报告\test\实验2.c(67) : error C2059: syntax error : ')' C:\Users\Administrator\Desktop\数据结构实验报告\test\实验2.c(67) : error C2143: syntax error : missing ';' before '{' C:\Users\Administrator\Desktop\数据结构实验报告\test\实验2.c(68) : error C2223: left of '->next' must point to struct/union C:\Users\Administrator\Desktop\数据结构实验报告\test\实验2.c(71) : error C2223: left of '->next' must point to struct/union C:\Users\Administrator\Desktop\数据结构实验报告\test\实验2.c(73) : error C2223: left of '->next' must point to struct/union C:\Users\Administrator\Desktop\数据结构实验报告\test\实验2.c(74) : error C2223: left of '->next' must point to struct/union C:\Users\Administrator\Desktop\数据结构实验报告\test\实验2.c(74) : error C2223: left of '->next' must point to struct/union C:\Users\Administrator\Desktop\数据结构实验报告\test\实验2.c(75) : warning C4022: 'free' : pointer mismatch for actual parameter 1 Error executing cl.exe. test.exe - 32 error(s), 6 warning(s)
10-24
c:\users\MAC\Desktop\clock_angle.c:1:10: error: '#include' expects '"FILENAME"' or '<FILENAME>' 1 | #include | ^ c:\users\MAC\Desktop\clock_angle.c:2:28: error: '#include' expects '"FILENAME"' or '<FILENAME>' 2 | #include // 鐢ㄤ簬fabs鍑芥暟 | ^ c:\users\MAC\Desktop\clock_angle.c: In function 'main': c:\users\MAC\Desktop\clock_angle.c:9:5: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration] 9 | printf("璇疯緭鍏ユ椂闂达紙灏忔椂 鍒嗛挓锛? "); | ^~~~~~ c:\users\MAC\Desktop\clock_angle.c:1:1: note: include '<stdio.h>' or provide a declaration of 'printf' +++ |+#include <stdio.h> 1 | #include c:\users\MAC\Desktop\clock_angle.c:9:5: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch] 9 | printf("璇疯緭鍏ユ椂闂达紙灏忔椂 鍒嗛挓锛? "); | ^~~~~~ c:\users\MAC\Desktop\clock_angle.c:9:5: note: include '<stdio.h>' or provide a declaration of 'printf' c:\users\MAC\Desktop\clock_angle.c:10:5: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration] 10 | scanf("%d %d", &hours, &minutes); | ^~~~~ c:\users\MAC\Desktop\clock_angle.c:10:5: note: include '<stdio.h>' or provide a declaration of 'scanf' c:\users\MAC\Desktop\clock_angle.c:10:5: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch] c:\users\MAC\Desktop\clock_angle.c:10:5: note: include '<stdio.h>' or provide a declaration of 'scanf' c:\users\MAC\Desktop\clock_angle.c:10:21: error: 'amp' undeclared (first use in this function) 10 | scanf("%d %d", &hours, &minutes); | ^~~ c:\users\MAC\Desktop\clock_angle.c:10:21: note: each undeclared identifier is reported only once for each function it appears in c:\users\MAC\Desktop\clock_angle.c:10:24: error: expected ')' before ';' token 10 | scanf("%d %d", &hours, &minutes); | ~ ^ | ) c:\users\MAC\Desktop\clock_angle.c:20:18: error: implicit declaration of function 'fabs' [-Wimplicit-function-declaration] 20 | angle_diff = fabs(hour_angle - minute_angle); | ^~~~ c:\users\MAC\Desktop\clock_angle.c:1:1: note: include '<math.h>' or provide a declaration of 'fabs' +++ |+#include <math.h> 1 | #inclu
09-04
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值