我有一个外部提供的.cpp文件.它是C兼容代码和一些C++的混合体.C++代码只是C的一个包装器,可以利用C++的特性.
它使用#ifdef __cplusplus宏来保护C++代码,这很棒.不幸的是,如果我尝试使用gcc进行编译,它会因为文件结束而将其视为C++.我知道gcc和g ++之间的区别 - 我不想编译为C++.
有什么方法可以强制gcc将此文件视为C文件吗?我尝试过使用eg --std=c99,但这正确地产生了C99对C++无效的错误.
将文件重命名为.c有效,但我想尽可能避免这种情况,因为它是外部提供的,并且保留为原始副本会很好.
谢谢!
当我运行我的Ant"build.xml"文件的"编译"目标时,我收到以下消息:
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Run Code Online (Sandbox Code Playgroud)
我的编译目标如下:
<target name="compile">
<javac srcdir="${src.dir}" destdir="${classes.dir}" debug="true" debuglevel="lines,source" includeantruntime="false">
<classpath refid="class.path" />
</javac>
<javac srcdir="${test.dir}" destdir="${classes.dir}" debug="true" debuglevel="lines,source" includeantruntime="false">
<classpath refid="class.path" />
</javac>
</target>
Run Code Online (Sandbox Code Playgroud)
我需要在build.xml文件中更改什么才能在那里完成-Xlint:unchecked?
十多年来,我的公司一直在Delphi上运行一个大型项目.我们的代码库多年来一直在增长,现在大约有400万行代码.编译速度正在成为一个问题.我们花了一些时间来清除单元循环引用(一种已知的慢速编译原因)并检查了设置的各个方面.我们无法通过我们可以控制的内容进一步改进它.
目前,在运行Windows XP SP3和Delphi 2006的4核处理器的最先进PC上,启动Delphi并进行全面构建,需要约40秒.然后,如果我们立即在同一个Delphi会话中进行另一次完整构建,则需要1m 40s.再做一次完整的构建,它会变得更糟.等等等等.
(我们很清楚Windows本身会缓存文件,这对编译速度有很大的影响.上面的数据是基于文件缓存的.我们通过让Delphi编译项目一次,终止它然后设置这样的场景开始一个新的Delphi会话.所以虽然40秒看起来并不慢,但这只是因为文件是由Windows缓存的.我们这样做是为了进行苹果到苹果的比较.)
令我们困惑的是为什么编译速度变得更糟.(我们在过去观察到,如果项目有很多单元循环引用,则减速更糟.)如果我们终止Delphi并开始一个新的会话,编译时间将回到40秒.我们观察到的一个更有趣的事情是,我们可以通过单击"取消"按钮中止编译来实现相同的速度"改进",然后立即完成整个构建.编译时间也将恢复到40秒.
在我们看来,Delphi自己的单元依赖缓存并不像从头开始构建它那样高效,而且随着时间的推移它变得越来越糟糕.并且它还会显示取消按钮以某种方式清除此缓存.我们的想法是,如果我们可以利用Delphi IDE子系统进行清除,我们可以始终将编译速度保持在最高性能.但我们不知道如何.
有谁知道我们能做什么?
我们仍在使用Delphi 2006,因为我们尚未找到将大型项目移植到Unicode的可行方法.我在论坛上看到最新的Delphi XE在单元循环引用方面表现出类似的编译速度问题.有人知道Delphi XE是否解决了这个问题?
ps我们也知道将项目拆分为运行时包可以减少编译时间.但出于部署和管理原因,我们尽量避免使用运行时包.
我只是想在编译时在我的Java类中使用maven占位符以减少重复.
像这样的东西:
的pom.xml
<properties>
<some.version>1.0</some.version>
</properties>
Run Code Online (Sandbox Code Playgroud)
SomeVersion.java
package some.company;
public class SomeVersion {
public static String getVersion() {
return "${some.version}"
}
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试编译一个调用一些导出函数的lua脚本,将生成的字节码保存到文件然后加载此字节码并执行它,但我还没有找到任何关于如何执行此操作的示例.有没有关于如何做到这一点的例子?我怎样才能做到这一点?
编辑:我正在使用Lua + Luabind(C++)
如果我定义一个没有实际主体的函数宏,它是否像编译器的空字符串(即它在编译时不生成任何额外的指令)?
例:
#define SomeMacro(a)
SomeMacro("hello"); // This line doesn't add any instructions, does it?
Run Code Online (Sandbox Code Playgroud) 根据该文件一个template可以是一个函数,它有两个参数,一个element和attributes并返回表示模板的字符串值.它用HTML的内容替换当前元素.替换过程将所有属性和类从旧元素迁移到新元素.
该compile函数处理转换模板DOM.它有三个参数,一个element,attributes和transclude功能.该transclude参数已被弃用.它返回一个link函数.
似乎a template和a compile函数非常相似,可以实现相同的功能.该template函数定义模板,compile函数修改模板DOM.但是,它可以在template函数本身中完成.我看不出为什么修改template函数外的模板DOM .反之亦然,如果可以在compile函数中修改DOM,那么函数的需求是template什么?
当我尝试在我的本地机器上编译我的项目的副本时,我收到一个错误,指出它正在跳过不兼容的库.当我正在处理服务器上托管的实时版本时,情况并非如此[它完全可以实现].
各种其他网站让我相信这可能是一个环境问题,因为我正在开发64位的Ubuntu发行版,我假设服务器版本运行在32位.然而,在将我的环境变量设置为:
CFLAGS+=" -m32"
CXXFLAGS+=" -m32"
Run Code Online (Sandbox Code Playgroud)
我仍然收到相同的编译错误:
/usr/bin/ld: skipping incompatible /dvlpmnt/libPI-Http.a when searching for -lPI-Http
Run Code Online (Sandbox Code Playgroud)
可以用教程吗?
== 编辑 ==
当我遵循乔纳森的建议时,这是我收到的输出:
http.o: ELF 32-bit LSB relocatable, Intel 80386, version 1 (SYSV), not stripped
Run Code Online (Sandbox Code Playgroud)
显然,有问题的库毕竟是32位的?
我最近买了一台新的MacBook,我转移了我的旧会话.从那时起,在我升级到10.13之后,我无法得到任何包括iostream在内的任何东西.
鉴于此计划:
#include <iostream>
int main(void)
{
std::cout << "Hello world !" << std::endl;
return 0;
}
Run Code Online (Sandbox Code Playgroud)
在以下时间给出我的输出g++ main.cpp:
In file included from main.cpp:1:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/iostream:38:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/ios:216:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/__locale:15:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/string:470:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/string_view:171:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/__string:56:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/algorithm:640:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/memory:629:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/typeinfo:61:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/exception:82:
In file included from …Run Code Online (Sandbox Code Playgroud)