完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
X如何在XC8中包含“文件”工作?看起来XC8使用当前的工作目录(正在编译的文件目录)作为搜索路径的一部分,我期待使用标准的(GCC)方法来执行执行包含“文件”的文件的目录。是否有一种方法来配置包含更像GCC的工作?真正让我困惑的是,它有时像我预期的那样工作(使用当前的文件目录而不是编译的文件目录)。这是MCC项目的一个很好的例子。Mc.c包括“McCyPrimeAddixFields/MCC.H”,然后MCC.H包含与“MCCGEngEngyAdsFixs/”相关的文件,但没有路径标识符(EX:Oy包括“PixMealth.h”)。如果你编译Maun.C,那么它发现PixMealth.h很好,即使“McCyPrimeAdxFrase/”不在包含路径中。有趣的是,当我移动McCyPrimeAddioFixs/从一个项目到另一个项目时,我开始遇到了一些问题。我们不在同一个目录中,因为我缺少了什么?我知道这似乎是一个愚蠢的问题,但我不是一个完全愚蠢的白痴。我能够重新创建一个文件在XC8中编译但不会在GCC中编译的情况。
以上来自于百度翻译 以下为原文 How does #include "file" work in XC8? It looks like XC8 uses the current working directory (directory of file being compiled) as part of the search path, I was expecting the more standard (GCC) method of using the directory of the file performing the #include "file". Is there a way to configure the #include to work more like GCC's? What really confuses me is that sometimes it works as I expect (uses current file directory instead of compiled file directory). A good example of this is any MCC project. main.c includes "mcc_generated_files/mcc.h", and then that mcc.h includes files relative to "mcc_generated_files/" but without a path identifier (ex: #include "pin_manager.h"). If you compile main.c then it finds pin_manager.h just fine even though "mcc_generated_files/" isn't in the include path. Interestingly I started having problems with #include when I moved the mcc_generated_files/ from one project to another, at which point it said couldn't find pin_manager.h on files not in the same directory as mcc_generated_files/. What am I missing? I know this seems like a dumb question, but I'm not a total dumb idiot. I was able to recreate a situation where a file wouldn't compile in XC8 but would in GCC. |
|
相关推荐
7个回答
|
|
可以在项目设置中向项目中添加其他搜索路径。
以上来自于百度翻译 以下为原文 You can add additional search paths to the project, in the project settings. |
|
|
|
|
|
|
|
我看到了,但是“WorkDirectory”看起来很模糊,因为我不知道它是否意味着项目、单元或文件中包含的内容。无论是哪种方式,XC8和AY都似乎存在差异,并且被认为是“工作目录”。基本上,如果你做了一个包含并提供一个路径,那么XC8将工作目录更改为该路径,并且从该文件中包含的任何文件都与该文件(已更改的工作目录)相对应。路径不必是满的,它可以是相对于当前文件的。但是,如果你做了一个包含并且不提供路径的编译器,那么编译器就可以使用“包含”路径,那么工作目录保持不变,并且包含在该文件中的“X”不会发现文件中包含的文件包含了“γ”,我不认为这是正确的行为。海湾合作委员会的行为不是这样的。甚至MPLAB X都不这样做,右键单击“包含”和“选择导航到声明”打开了我所期望的文件。为了展示这种差异,我用3种配置制作了一个简单的MPLABX项目。TestEtFuleLay引号配置显示,包含在包含语句中的路径更改工作目录,而其他2种配置表明,通过包含路径打开文件不会更改工作目录。在3种配置中,GCC工作(有一个简单的BAT文件,所有3个要测试)。在3种配置中,MPLABX IDE都用于打开正确的文件(右键单击“包含”并导航到“定义”),即使XC8本身表示无法找到。MPLABX项目可以找到AtTTPs//Delix.com……1GxM9VQZ2RFD2Z6AM9CBJA。
以上来自于百度翻译 以下为原文 I saw that, but "working directory" seemed vague because I didn't know if it meant the project, the unit, or the file doing the including. Either way, there does seem to be a discrepancy in XC8 and #include and what is considered the "working directory". Basically, if you do an #include and provide a path then XC8 changes the working directory to that path and any files included from that file are relative to that file (the changed working directory). The path doesn't have to be full, it can be relative to the current file. But if you do an #include and don't provide a path, instead having the compiler use the #include path, then the working directory stays the same and the #includes in that file won't find the files in the directory of the file doing the #including. I don't feel like this is proper behavior. GCC doesn't behave like this. Not even MPLAB X behaves like this, right clicking on the #include and selecting navigate to the declaration opens the files I expect. To showcase this discrepancy I made a simple MPLABX project with 3 configurations. The TEST_FULL_QUOTES configuration shows that including a path in the #include statement changes the working directory, whereas the other 2 configurations show that opening a file thru an include path does not change the working directory. In either 3 configurations GCC works (there's a simple bat file of all 3 to test). In either 3 configurations MPLABX IDE works for opening the correct file (right click on the #include and navigate to definition), even though XC8 itself says it cannot be found. The MPLABX project can be found at https://drive.google.com/...1GxM9vqZ2Rfd2Z6am9CbjA |
|
|
|
GCC不是标准,标准说几乎所有关于文件是如何定位的都是实现的。来自XC8团队的人可能会停下脚步,释放一些光。
以上来自于百度翻译 以下为原文 GCC isn't the standard, and the standard says pretty much everything about how include files are located is implementation-defined. Someone from the XC8 team might stop by and shed some light. |
|
|
|
GCC不是标准,标准说几乎所有关于文件是如何定位的都是实现的。来自XC8团队的人可能会停下脚步,轻松一下。约翰,你已经完成了一项艰巨的任务。
以上来自于百度翻译 以下为原文 GCC isn't the standard, and the standard says pretty much everything about how include files are located is implementation-defined. Someone from the XC8 team might stop by and shed some light. You've already done a stellar job, John. |
|
|
|
这是一个公平的评论。然而XC16和XC32是基于GCC的,这意味着XC8的工作方式与Microchip的其他编译器不一样。我想知道在AVR XC8中会发生什么,这也是基于GCC的。我认为MPLAB X可以找到文件和XC8这一事实不能说明XC8是错误的。
以上来自于百度翻译 以下为原文 That's a fair comment. However XC16 and XC32 are GCC based, meaning that XC8 does not work the same way as Microchip's other compilers. I wonder what will happen in AVR XC8, which is also GCC based. I think the fact that MPLAB X can find the file and XC8 cannot says that XC8 is in error. |
|
|
|
你是说你有一个包含XC8的文件,不管你提供的包含什么的指令,都不能打开。那是个错误。
以上来自于百度翻译 以下为原文 Are you saying you have an include file located somewhere that XC8 is unable to open regardless of the #include directive you provide? That would be an error. |
|
|
|
只有小组成员才能发言,加入小组>>
5142 浏览 9 评论
1990 浏览 8 评论
1918 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3159 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2215 浏览 5 评论
710浏览 1评论
598浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
481浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
610浏览 0评论
508浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-10 15:28 , Processed in 1.192787 second(s), Total 56, Slave 51 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号