由买买提看人间百态

topics

全部话题 - 话题: rtti
1 (共1页)
z******i
发帖数: 59
1
来自主题: Programming版 - 有大侠讲讲RTTI和exception的问题么?
Performance problem.
RTTI: dynamic cast is expensive
exception: extra codes are generated for stack unwinding. Even if they are
not used, extra code size means:
1. Load code from main memory to instruction cache. cache pollution.
2. CPU is pipe-lined, CPU still needs to decode the assembly codes.
3. In order to preserve stack, compiler might not be able to optimize the
local variables to register. Big performance hit.
w***y
发帖数: 78
2
来自主题: Programming版 - 用惯了RTTI,不让用好难啊
这什么的OO的原则太麻烦了,用RTTI简单多了,有同感的请re。
J*****n
发帖数: 4859
3
来自主题: JobHunting版 - 问个题目 C++
A power switch is required that can turn on or off any number of appliances.
An appliance is, for example, a Blender, a Toaster, or an Oven.
Other programmers have already written those appliances and you can't change
their source code. For example, you cannot require them all to implement a
particular interface.
Fortunately, each such appliance already has two methods to turn its
particular appliance on and off.
Unfortunately, all such methods were written by different people and have
differen... 阅读全帖
w***g
发帖数: 5958
4
来自主题: GunsAndGears版 - 用短波收音机玩ham radio
最近带小孩去hands-on meuseum玩,然后就中了ham radio的毒。
发现短波tranceiver至少要好几百,而且还要折腾天线,实在搞不起。
最后买了个德生PL-880充当receiver。发现用单边带还真能接受到
ham信号。然后用麦克风直接输入电脑,竟然可以直接用fldigi解码。
贴几个录下来的音频,用fldigi replay或者用音箱播放同时
用麦克风读入都可以解码。
摩尔斯码
http://anna.wdong.org/radio/201412012045-7046-cw17.wav
RTTY
http://anna.wdong.org/radio/201412012127-3596-rtty.wav
bpsk31
http://anna.wdong.org/radio/201412012127-3597-bpsk31.wav
穷人有穷人的玩法,哈哈。
d******i
发帖数: 7160
5
来自主题: TVChinese版 - PPS限制升级了?
试了,不灵啊。
root@debian:~/nodejs/node-v0.10.1# make
make -C out BUILDTYPE=Release V=1
make[1]: Entering directory `/root/nodejs/node-v0.10.1/out'
g++ '-DENABLE_DEBUGGER_SUPPORT' '-DENABLE_EXTRA_CHECKS' '-DV8_TARGET_ARCH_
ARM' '-DUSE_EABI_HARDFLOAT=0' -I../deps/v8/src -Wall -Wextra -Wno-unused-
parameter -pthread -fno-strict-aliasing -O2 -fno-strict-aliasing -fno-tree-
vrp -fno-tree-sink -fno-tree-vrp -fno-rtti -fno-exceptions -MMD -MF /root/
nodejs/node-v0.10.1/out/Release/.deps//root/nodejs/node... 阅读全帖
s*******d
发帖数: 59
6
来自主题: Programming版 - A C++ runtime type casting question
抄一段
http://blog.vckbase.com/bruceteen/archive/2004/09/13/811.aspx
问:在c++里怎么能知道一个变量的具体类型,如:c#里的typeof.还有我怎么知道一个
变量的类型是某个类型的子类,也就是实现关键字IS
答:
1。运行时获知变量类型名称,可以使用 typeid(变量).name,需要注意不是所有编译
器都输出"int"、"float"等之类的名称,对于这类的编译器可以这样使用:float f =
1.1f; if( typeid(f) == typeid(0.0f) ) ……
2。对于多态类实例,想得到实际的类名称,需要使用到RTTI,这需要在编译的时候加
上参数"/GR"。
3。对于普通变量,既然是自己写的,那当然也就应该知道它的类型,其实用不着运行
时获知;对于多态类实例,既然需要运行时获知实际类型,那么就说明这里不具有多态
性,既然没有多态性就不应该抽象它,这属于设计错误,总之,我认为RTTI是多余的。
4。对于多态类实例,使用 typeid(value) == typeid(value)来判断,不如使用
dyn
t****t
发帖数: 6806
7
来自主题: Programming版 - C++0x
you use RTTI to achieve reflection-like effect. template has nothing to do
with it. C++ RTTI is very limited, and if you want to use that for
reflection it's going to be awkward. macro is probably better.
t****t
发帖数: 6806
8
来自主题: Programming版 - C++0x
no, not complete yet. when you have no access to name of member/class/object
, essentially you have no way to do reflection. the missing piece is the #
name operator in preprocessor; if you don't have it, you have a big missing
chain in the machine. so as you see, every "reflection simulator" library
use macro here or there.
i don't mean macro is reflection. but in current standard, the #name
operator is almost the only way to implement reflection-like mechanism in a
library. as for template, of... 阅读全帖
b***e
发帖数: 1419
9
来自主题: Programming版 - scala ts 的复杂
你这个说法有点儿意思。一般来讲duck type和strongly typed是不两立的。但是你这
个说法确实有意义。其实GADT的本质是吧runtime type identification变成了一个
first class value。在Java里可以说
o instanceOf Integer
如果用GADT的方式就变成了
o.type == rttiOfInteger
GADT的expressiveness在于等式的右侧可以是variable, like
o.type == rttiOfSomeType
而instanceof的右侧只能是一个type, which is not a first class value。
GADT还有一个好处是type constructor也可以有rtti as first class (higher order)
value。For instance:
o.type == rttiOfArray(rttiOfInteger)
这就是判断o的type是不是[Int]。我印象里Java的rtti由于历史原因无法支持higher
order va... 阅读全帖

发帖数: 1
10
来自主题: Military版 - 半导体这种材料只能两种状态吗

=====================
C++ 工程实践(4):二进制兼容性
原创 2011年03月09日 10:46:00 标签:c++ /library /interface /mfc /class /编译
器 22578
陈硕 (giantchen_AT_gmail)
Blog.csdn.net/Solstice
本文主要讨论 Linux x86/x86-64 平台,偶尔会举 Windows 作为反面教材。
C/C++ 的二进制兼容性 (binary compatibility) 有多重含义,本文主要在“头文件和
库文件分别升级,可执行文件是否受影响”这个意义下讨论,我称之为 library (主
要是 shared library,即动态链接库)的 ABI (application binary interface)。至
于编译器与操作系统的 ABI 留给下一篇谈 C++ 标准与实践的文章。
什么是二进制兼容性
在解释这个定义之前,先看看 Unix/C 语言的一个历史问题:open() 的 flags 参数的
取值。open(2) 函数的原型是
int open(cons... 阅读全帖
t****9
发帖数: 1100
11
来自主题: Military2版 - 这里有玩业余无线电的嘛?
不全是,话音通讯只是ham的其中一个操作模式还有cw电报,rtty无线电传,pocket封
包数据,sstv慢扫描电视,无线电传真,atv业余电视等等。 不过无线电监听不是业余
无线电。
m*********2
发帖数: 701
12
LZ不如谈下这low-level detail.
For example:
1) How is Node** p represented in the low level?
p, the pointer to pointer to a Node, is on the stack?
where is *p located then? on the stack or the heap?
My understanding is:
Node p ==> the struct is on the stack.
Node *p ==> the pointer is on the stack, the struct is on heap
Node **P ==> the pointer of pointer is on the stack... not sure where
the other two is going to be.
In addition, does the complier keep track of RTTI of p (in case of Node
**p)? Does t... 阅读全帖
m********l
发帖数: 4394
13
what's not wrong about the code?
------------
actually, in c# it's definitely wrong.
How about C++?
does the RTTI check it?
a********m
发帖数: 15480
14
来自主题: JobHunting版 - 请问这是什么level的面试题
dynamic会根据RTTI检查合法性,也看你的编译选项。这个是基本知识,不高级,但是
这个cast还是做了一些事情的。
如果你的dynamic cast返回null说明你的cast有问题。static强制过去了虽然成功了但
是实际是错的。不是说“要用static_cast”。
a********m
发帖数: 15480
15
来自主题: JobHunting版 - 请问这是什么level的面试题
dynamic会根据RTTI检查合法性,也看你的编译选项。这个是基本知识,不高级,但是
这个cast还是做了一些事情的。
如果你的dynamic cast返回null说明你的cast有问题。static强制过去了虽然成功了但
是实际是错的。不是说“要用static_cast”。
k****e
发帖数: 116
16
不知道RTTI是否可以做到
d******i
发帖数: 7160
17
来自主题: TVChinese版 - PPS限制升级了?
多谢指点。
俺在pogoplug的debian下按照 https://github.com/joyent/node/wiki/Installing-
Node.js-via-package-manager 的debian编译指示去做,
结果最后一步出错了:
root@debian:~/nodejs/node-v0.10.1# make install
make -C out BUILDTYPE=Release V=1
make[1]: Entering directory `/root/nodejs/node-v0.10.1/out'
g++ '-DENABLE_DEBUGGER_SUPPORT' '-DENABLE_EXTRA_CHECKS' '-DV8_TARGET_ARCH_
ARM' '-DUSE_EABI_HARDFLOAT=0' -I../deps/v8/src -Wall -Wextra -Wno-unused-
parameter -pthread -fno-strict-aliasing -O2 -fno-strict-aliasing -fno-tree-
v... 阅读全帖
d******i
发帖数: 7160
18
来自主题: TVChinese版 - PPS限制升级了?
下面这段是从 https://github.com/joyent/node/wiki/Installing-Node.js-via-
package-manager 抄来的哈:
Debian
Node.js is available in official repo for Debian Sid(unstable).
For Debian Squeeze, your best bet is to compile node by yourself (as root):
apt-get install python g++ make
mkdir ~/nodejs && cd $_
wget -N http://nodejs.org/dist/node-latest.tar.gz
tar xzvf node-latest.tar.gz && cd `ls -rd node-v*`
./configure
make install
我最后一步"make install"没过。
按你的说法,./configure以后我试着make,结果一样的错误:
root@debian:~/nodejs/no... 阅读全帖
m*d
发帖数: 7658
19
来自主题: TVChinese版 - PPS限制升级了?
下载tarball自己make 和make install是本地编译
apt-get install是下载官方make好的binary,结果都一样,就是有了执行文件
make install没通过,apt-get install成功了一样啊
怎么会“所以其后续的用法npm install -g ub.uku.js,ub.uku.js 都不适用"
你试一下npm 能不能有不就知道了
用这个patch,make应该就可以通过了,怎么用patch,去Google吧,
或者直接修改文件deps/v8/SConstruct也行
diff –git a/deps/v8/SConstruct b/deps/v8/SConstruct
index 1dcdce4..a5aaf50 100644
— a/deps/v8/SConstruct
+++ b/deps/v8/SConstruct
@@ -79,7 +79,7 @@ LIBRARY_FLAGS = {
},
‘gcc’: {
‘all’: {
- ’CCFLAGS’: ['$DIALECTFLAGS', '$WARNINGF... 阅读全帖
m**i
发帖数: 89
20
来自主题: Java版 - Java中如何动态生成对象

See RTTI (Run-Time Type Identification) manual.
Basically, use Class and its instance functions
v**d
发帖数: 186
21
来自主题: Java版 - Java sucks big time!

Thus there are too many bugs in Java? LOL!
How about the transfer and manangement of large volume of data, say mirroring
a remote server for local cache?
well what i have to say is that it is really trivial ....... take a look at
the source code of Java Mustang you will know....
it really depends on what you are doing
java has some advantages over c++, e.g RTTI/reflection
but for some apps that performance is crucial we have to use c++, and some
apps demand the using of c++, such as isapi exten
W*****x
发帖数: 684
22
$ cd geoip-api-c-master
$ libtoolize
$ aclocal
$ autoconf
$ automake --add-missing
$./configure
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
... 阅读全帖
q*****g
发帖数: 72
23
来自主题: Programming版 - c++里如何判断是哪种object?
don't do this, use polymorphism instead.
if you really want to do this, use RTTI, such as typeid operator.
z******i
发帖数: 59
24
来自主题: Programming版 - c vs c++
最近在做程序优化,感觉用C++比用C更容易写慢的代码
我们有段代码,没用任何try-catch,简单的compiler setting 去掉
exception handling, 快了35%.
后来决定所有要快的程序,都去掉exception handling, RTTI, 基本上
就只用C99的语法。
感觉 OO 对 embedded system 不是太管用。Compiler 也更容易优化
C 程序。
c*****t
发帖数: 1879
25
来自主题: Programming版 - 继承应该在什么场合用?
Whether or not the person is blind or deaf, that's a property. Although
you could use inheritance (through marker interface), such approach is
usually bad or mostly for convenience. It also requires RTTI. Using
properties give you a lot more freedom in adding new diseases / physical
impairments and such. Basically you have two functions
setProperty (key, value);
getProperty (key);
where key is a constant such as BLIND / DEAF, where value could be boolean
such as true / false or other objects
f*******y
发帖数: 988
26
来自主题: Programming版 - 有大侠讲讲RTTI和exception的问题么?
为啥不建议使用呢?主要问题在哪里?
X****r
发帖数: 3557
27
来自主题: Programming版 - 有大侠讲讲RTTI和exception的问题么?
谁不建议使用就问谁啊。
如果你这个是对于早先有人贴的Google Style Guide所问的,
你看了上面每条规定所对应的详细解释吗?
Google的理由并不是对所有人都成立的。
r*********r
发帖数: 3195
28
来自主题: Programming版 - 有大侠讲讲RTTI和exception的问题么?
太复杂,属于让你 shoot your own foot 部分,禁了比较好,
程序出错少。尤其对于古狗那些比较傻的。
r*********r
发帖数: 3195
29
来自主题: Programming版 - 有大侠讲讲RTTI和exception的问题么?
i think exception has a more damaging problem.
that is, it will cause memory leak, when the exceptional path is taken.
especially when exceptions are thrown from constructors and destructors.
using RAII may solve the problem if the exception is thrown by constructor.
but the ones thrown by destructors are truly problematic.
g*****y
发帖数: 7271
30
来自主题: Programming版 - 有大侠讲讲RTTI和exception的问题么?
I actually quite disagree this opinion. When discussing the good/bad of
exception. You have to think about when you should use it? If it is not good
, what are the alternatives? Do the alternatives solve the problem of
exception?
You should use exception when you have errors that cause the function cannot
finish its task. For example, you cannot get the memory you need from new/
malloc. If you do not use exception, you usually return error code. You
still have different excution path for errors
s***e
发帖数: 122
31
来自主题: Programming版 - Does VC++ 6.0 not support dynamic cast?
You could turn on the RTTI (in Project->Setting->C/C++->C/C++ Language) to
avoid this. You should have noticed the warning C4541: 'dynamic_cast' used
on polymorphic type ...
Anyway, this should be part of the C++ language, not an option.
b***y
发帖数: 2799
32
来自主题: Programming版 - [合集] Google C++ Coding Standard
☆─────────────────────────────────────☆
fishdaddy (无) 于 (Sun Jun 29 11:03:03 2008) 提到:
http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml
呵呵,有几个出人意料的地方
exception, stream,overloading,RTTI 都在尽可能被禁止之列
☆─────────────────────────────────────☆
zhangfei (Leo Kamis) 于 (Sun Jun 29 11:56:54 2008) 提到:
No surprise for me.
It was not once near the release of the product, a crisis team
was formed to undo the damage of these C++ feature.
☆─────────────────────────────────────☆
vvs (vvs
e*****w
发帖数: 144
33
来自主题: Programming版 - template: return true if T is int
第二种好。第一种需要RTTI支持,运行时确定。第二种编译时就确定了。
h*******e
发帖数: 225
34
来自主题: Programming版 - pointer to class, which class?
RTTI or similar reflection tricks. But why do you need to do this?
k****5
发帖数: 546
35
来自主题: Programming版 - 有段c++代码看不懂
可以编译。 作者写的是一个叫enhanced RTTI, 就是没有vtable, 也能dynamic_cast。
起码对我来说晦涩难懂,
倒不是太长,90行,想看我可以放上来
d****p
发帖数: 685
36
来自主题: Programming版 - 再问C++问题。
没有虚表,类型编译时就可知,要RTTI干嘛?
s*******e
发帖数: 432
37
来自主题: Programming版 - 请教显示object name的问题(c++)
you can use RTTI (run-time type information) you can google to see how to
use it
c*****s
发帖数: 49
38
来自主题: Programming版 - 请教显示object name的问题(c++)
Thank you for your answer. However, after reading some info online, it seems
RTTI deals with the type of the object only (esp. for hiearchies of
inherited classes). I could not figure out how to use it to infer the object
name. Please let me know if I'm missing something. Thanks.
t****t
发帖数: 6806
39
来自主题: Programming版 - C++ vs Java
class本身还好, 如果牵涉到别的东西比如exception, rtti, 那就会比较慢了. 再加上
写OS本身不太好用STL, c++的特性就没剩下什么了, 那为什么不用C?
y*d
发帖数: 2226
40
来自主题: Programming版 - inline到底能省多少时间?

ODR是说你不能乱来,不是说compiler不能
举个例子
template
T add(const T& a, const T& b)
{
return a+b;
}
这个函数你放在.h里,有十个cpp里用过add()
那就有十个.o或者.obj都含有add
但是link的时候,会把多余的干掉
80年代的template实现要把所有的function都inline,还不吃static variable
但是90年代以后编译器就已经灰墙强悍了
ODR是为了帮你检查错误,怕你写了两个不同的define
对编译器自己,没这么多规矩
再举个例子,有虚函数的class都有个vtable
override和rtti都靠这个
请问这个vtable是在哪个.o里?
答案是每个.o里都有一个。因为编译器编译这个文件的时候,不知道别的.o里是否已经
有了,所以只能
是先放进去一个再说
然后呢?
link的时候,编译器会删掉多余的,只留一个
L**Q
发帖数: 834
41
这是C++ virtual function最基本的概念吧,RTTI。
Base class定义pure virtual function做为interface,derived class override
virtual function,run time link。
不是virtual function,返回base pointer被upcast成base class pointer,相当于
object被slice copy,当然不能访问derived class member function了。
w*s
发帖数: 7227
42
来自主题: Programming版 - c++ template跟RTTI扯得上吗?
a**e
发帖数: 64
43
来自主题: Programming版 - c++ template跟RTTI扯得上吗?
听起来就不一样。一个是compile time,一个是runtime。
x****u
发帖数: 44466
44
来自主题: Programming版 - c++ template跟RTTI扯得上吗?
有混一起用的。
w*s
发帖数: 7227
45
来自主题: Programming版 - c++ template跟RTTI扯得上吗?
any sample/post on this pls ?
d****i
发帖数: 4809
46
来自主题: Programming版 - 嵌入式的一个架构思考
用Linux的一个好处是很多driver都有现成的,其他的OS就有可能有些要自己写,另外
你说的C++ compiler的问题确实存在,我们用的Greenhill的C++ compiler也有点bug,
所以很多时候就基本全部用C了,用C++的话也都是用的最基本的feature,没有模版STL
,没有多继承,没有RTTI,少了很多overhead,也少了很多出错的机会。
M*****R
发帖数: 650
47
C++是没有Reflection啊,RTTI还差点老远。
Reflection对Java太重要了,从C++过来的人,好多都没听说过什么叫DI,AOP, etc.
更没有想过在C++里哼哧哼哧自己实现的一些Design Pattern,用Java的一些framework
,几行就解决了。
d****i
发帖数: 4809
48
这个feature还是很不好,C++一直是高举三面大旗得以屹立不倒:
1)对C语言的完全兼容和遵循C的规范和理念
2)对performance下降的零容忍
3)坚持静态类型检查,只用极少量的RTTI这样的
这个in-class member initialization非但违反了C++自己的准则,也违反了C的传统准
则,声明归声明,定义归定义,应该分开。我觉得C++越是想向Java学越是不好,反而
搞得四不像,倒是坚持上述三面大旗更好。C++就是因为一开始就是作为带类的C的扩展
产生的,要是语言feature越搞越多反而不好,最后变个四不像。
k***e
发帖数: 1931
49
也许理解的不对。CatData从AnimalData继承,那么CatData is a AnimalData,
processData使用(AnimalData*)作为参数,在Cat类中用RTTI判断指针指向的对象是
不是一个CatData不就行了吗?
x****u
发帖数: 44466
50
来自主题: Programming版 - 国内的编程论坛很不自由
禁了rtti也不该用static_cast做downcast或者sidecast,可以试试类似COM的做法。
dynamic_cast的最大意义是容许文雅的转换失败。

cast了
1 (共1页)