看起来很容易找到这样的Java工具(Checkstyle,JCSC),但我似乎找不到一个用于C/C++的工具.我不是在寻找类似于lint的静态代码分析器,我只想检查编码标准,如变量命名,大小写,间距,标识,括号放置等.
我正在寻找一种工具,可以为不同的编译器(gcc,microsoft vc ++,borland等)和不同的平台(Win,Linux,Mac)生成用于C/C++项目的makefile.
我正在寻找一篇关于使用emacs作为C/C++ IDE的好文章.
像Steve Yegge的"有效的emacs".
我目前正在开发一个宠物项目,需要在Windows,Mac,Linux和Solaris上进行C++开发,我将其缩小到Netbeans和Eclipse,所以我很奇怪,它作为C++编辑器更加稳固.我只需要可靠的编辑,模板化代码和外部库的良好自动完成,以及项目文件管理,构建工具都是外部的,所以这与我的比较无关.
那么这是一个更好的选择呢?
注意:我知道我应该使用emacs或vim,但问题是,至少我的理论是,我是左撇子,因此我使用大脑的右侧(设计,创造力)而不是左侧(逻辑) ,记忆),所以我只是简单地不能使用emacs或vim,我的大脑根本就不兼容,我也尝试了很多次,甚至使用emacs几个月但是它让我发疯了...
谢谢
我们在项目中进行了大量的浮点到整数转换.基本上,这样的事情
for(int i = 0; i < HUGE_NUMBER; i++)
int_array[i] = float_array[i];
Run Code Online (Sandbox Code Playgroud)
执行转换的默认C函数非常耗时.
是否有任何工作(可能是手动调整功能)可以加快一点点的过程?我们不太关心精度.
在过去的6到7年里,我是一名C++程序员(在Unix和gcc 3.x上).我已经阅读了Scott Meyer的Effective C++,更有效的C++和有效的STL封面,并且与Boost一起生活和实践了他的建议/技巧.我想继续学习C++的更高级方面 - 这与Andrei Alexandrescu的"现代C++设计"类似.然而,在开始阅读本文之前,我想知道我是否应该花时间阅读Herb Sutter的Exceptional C++书籍.你如何将Effective C++系列与Sutter的书籍进行比较?
非常感谢您的回复.
我有下一个代码:
#include <iostream>
#include <algorithm>
#include <map>
#include <iterator>
//namespace std
//{
std::ostream& operator << ( std::ostream& out,
const std::pair< size_t, size_t >& rhs )
{
out << rhs.first << ", " << rhs.second;
return out;
}
//}
int main()
{
std::map < size_t, size_t > some_map;
// fill some_map with random values
for ( size_t i = 0; i < 10; ++i )
{
some_map[ rand() % 10 ] = rand() % 100;
}
// now I want to …
Run Code Online (Sandbox Code Playgroud) 这个编译和工作应该(非嵌套模板):
#include <iostream>
template<typename T> class Z;
template <typename T>
std::ostream& operator<< (std::ostream& os, const Z<T>&) {
return (os << "Z");
}
template<typename T> class Z {
friend std::ostream& operator<< <> (std::ostream& os, const Z&);
};
int main () {
Z<int> z;
std::cout << z << std::endl;
}
Run Code Online (Sandbox Code Playgroud)
这个不编译(gcc 4.4和gcc 4.6,在03和0x模式下):
#include <iostream>
template<typename T> class Z;
template<typename T>
std::ostream& operator<< (std::ostream& os, const typename Z<T>::ZZ&) {
return (os << "ZZ!");
}
template <typename T> class Z {
public:
class …
Run Code Online (Sandbox Code Playgroud) 假设我有一些基类A和两个派生类B和C.类A有一些叫做f()的方法.
有没有办法在visual studio中的A :: f()中设置条件断点,只有当我的'this'实际上是C类的实例时才会被击中?
例如
void A::f()
{
some code and a breakpoint
}
void foo(A* a)
{
a->f();
}
void bar()
{
A a;
B b;
C c;
foo(&a); // breakpoint isn't hit
foo(&b); // breakpoint isn't hit
foo(&c); // breakpoint is hit
}
Run Code Online (Sandbox Code Playgroud)
我已经设法通过在断点条件下测试虚拟表指针来实现它,但必须有一个更好(更简单)的方法.
提前致谢.
编辑:修改注释中建议的源代码并不是我正在寻找的解决方案.它必须通过VC++调试器完成.
我的项目基于spring framework 2.5.4.我尝试为某些控制器添加方面(我使用aspectj 1.5.3).
我在application-servlet.xml中启用了自动代理,只是将这些行粘贴到xml文件的末尾:
<aop:aspectj-autoproxy />
<bean id="auditLogProcessor" class="com.example.bg.web.utils.AuditLogProcessor" />
Run Code Online (Sandbox Code Playgroud)
创建方面:
package com.example.bg.web.utils;
import org.apache.log4j.Logger;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
@Aspect
public class AuditLogProcessor
{
private final static Logger log = Logger.getLogger(AuditLogProcessor.class);
@After("execution(* com.example.bg.web.controllers.assets.AssetThumbnailRebuildController.rebuildThumbnail(..))")
public void afterHandleRequest() {
log.info("test111");
}
@After("execution(* com.example.bg.web.controllers.assets.AssetThumbnailRebuildController.rebuildThumbnail(..))")
public void afterRebuildThumbnail() {
log.info("test222");
}
}
Run Code Online (Sandbox Code Playgroud)
我的控制器:
class AssetAddController implements Controller
class AssetThumbnailRebuildController extends MultiActionController
Run Code Online (Sandbox Code Playgroud)
当我在方面顾问和调用控制器中设置制动点时,我只捕获afterHandleRequest()而不是afterRebildThumbnail()我做错了什么?
注意
我代表我的朋友问这个问题,他不能访问SO beta,我也不知道它是什么.
编辑
确实有一些拼写错误,谢谢Cheekysoft.但问题仍然存在.
c++ ×9
c ×3
coding-style ×1
debugging ×1
eclipse ×1
emacs ×1
java ×1
makefile ×1
namespaces ×1
netbeans ×1
optimization ×1
performance ×1
spring ×1
spring-aop ×1
stl ×1
templates ×1
visual-c++ ×1