由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - typedef
相关主题
c++ initialize structQuestion about friend in C++
forward declarationA C++ Question
a question about CASTWhat is wrong in this array declaration.
关于C++ STL编译的疑问请教有关header file的几个问题
class D:public B;qeustion about separation of interface and implementation in java
C++ memcpy declaration use restrict keyword?Compile issues
码工试题 (转载)why int** cannot convert to const int** ?
what's wrong with this C++ code?a simple question about constructor
相关话题的讨论汇总
话题: list话题: rrc话题: typedef话题: struct话题: code
进入Programming版参与讨论
1 (共1页)
n**d
发帖数: 9764
1
Found this from a opensurce code, but it can not pass my compiler. How does
it work?
typedef struct rrc_List {
struct rrc_List *next;
int value;
} *rrc_List;
k****e
发帖数: 100
2
贴出你的compiler版本
另外,把最后一个 rrc_List 换个名字看看。

does

【在 n**d 的大作中提到】
: Found this from a opensurce code, but it can not pass my compiler. How does
: it work?
: typedef struct rrc_List {
: struct rrc_List *next;
: int value;
: } *rrc_List;

n**d
发帖数: 9764
3
g++ 3.4.4.
把最后一个 rrc_List 换个名字, of course it works. However, We are not suppose to modify the 3rd party code.

【在 k****e 的大作中提到】
: 贴出你的compiler版本
: 另外,把最后一个 rrc_List 换个名字看看。
:
: does

k**f
发帖数: 372
4

Then why use opensource code, which is meant to be modified if it doesn't
work for you?

【在 n**d 的大作中提到】
: Found this from a opensurce code, but it can not pass my compiler. How does
: it work?
: typedef struct rrc_List {
: struct rrc_List *next;
: int value;
: } *rrc_List;

n**d
发帖数: 9764
5
I don't think you know how companies use the opensouce resource. Anyway,
that has nothing to do with this topic.
Let us concentrate on the code. Is it wrong?

【在 k**f 的大作中提到】
:
: Then why use opensource code, which is meant to be modified if it doesn't
: work for you?

K****n
发帖数: 5970
6
typedef 把一个struct变成 struct*, 没见过这种用法.
一般都是
typedef struct myStruct{
...;
} myStruct;吧

【在 n**d 的大作中提到】
: I don't think you know how companies use the opensouce resource. Anyway,
: that has nothing to do with this topic.
: Let us concentrate on the code. Is it wrong?

n****g
发帖数: 150
7
probably the previous standard treats "struct xxx" and "xxx" as different
declarations, so it worked at that time.
not sure.
r********d
发帖数: 23
8
This definitely works with a C compiler; but it's an error with a C++
compiler

does

【在 n**d 的大作中提到】
: Found this from a opensurce code, but it can not pass my compiler. How does
: it work?
: typedef struct rrc_List {
: struct rrc_List *next;
: int value;
: } *rrc_List;

n**d
发帖数: 9764
9
You are right. It passes C compiler. Then it comes how to understand the
code.
The rrc_List should be used to define a pointer which points to the
structure, right?

【在 r********d 的大作中提到】
: This definitely works with a C compiler; but it's an error with a C++
: compiler
:
: does

K****n
发帖数: 5970
10

冲突的原因估计是:
rrc_List 本来是struct名,现在变成了rrc_List*
我试了下(先不typedef成指针),c++里声明struct可以用
rrc_List rrc_list;//绕过 struct rrc_List rrc_list;
现在typedef以后声明
rrc_List不知道是在说指针还是说他自己.

【在 n**d 的大作中提到】
: You are right. It passes C compiler. Then it comes how to understand the
: code.
: The rrc_List should be used to define a pointer which points to the
: structure, right?

相关主题
C++ memcpy declaration use restrict keyword?Question about friend in C++
码工试题 (转载)A C++ Question
what's wrong with this C++ code?What is wrong in this array declaration.
进入Programming版参与讨论
K****n
发帖数: 5970
11
所以如你所知,换个名字就work了

【在 K****n 的大作中提到】
: 对
: 冲突的原因估计是:
: rrc_List 本来是struct名,现在变成了rrc_List*
: 我试了下(先不typedef成指针),c++里声明struct可以用
: rrc_List rrc_list;//绕过 struct rrc_List rrc_list;
: 现在typedef以后声明
: rrc_List不知道是在说指针还是说他自己.

T*****9
发帖数: 2484
12
typedef struct A{} *A?

does

【在 n**d 的大作中提到】
: Found this from a opensurce code, but it can not pass my compiler. How does
: it work?
: typedef struct rrc_List {
: struct rrc_List *next;
: int value;
: } *rrc_List;

r*******y
发帖数: 290
13
Avoid using open source code
free means nobody is responsible for it
it's a pain in the ass if your code gets bigger and bigger
and there is a memory leak in the 3rd party code...you dont want that

suppose to modify the 3rd party code.

【在 n**d 的大作中提到】
: g++ 3.4.4.
: 把最后一个 rrc_List 换个名字, of course it works. However, We are not suppose to modify the 3rd party code.

r********d
发帖数: 23
14
laf...

【在 r*******y 的大作中提到】
: Avoid using open source code
: free means nobody is responsible for it
: it's a pain in the ass if your code gets bigger and bigger
: and there is a memory leak in the 3rd party code...you dont want that
:
: suppose to modify the 3rd party code.

f******y
发帖数: 2971
15
funny

【在 r*******y 的大作中提到】
: Avoid using open source code
: free means nobody is responsible for it
: it's a pain in the ass if your code gets bigger and bigger
: and there is a memory leak in the 3rd party code...you dont want that
:
: suppose to modify the 3rd party code.

d******n
发帖数: 42
16
d******n
发帖数: 42
17
Using open source code is ok, just avoid using the code that is not
maintained.
1 (共1页)
进入Programming版参与讨论
相关主题
a simple question about constructorclass D:public B;
C arrayC++ memcpy declaration use restrict keyword?
boost::function 的 syntax 问题码工试题 (转载)
关于传递函数指针what's wrong with this C++ code?
c++ initialize structQuestion about friend in C++
forward declarationA C++ Question
a question about CASTWhat is wrong in this array declaration.
关于C++ STL编译的疑问请教有关header file的几个问题
相关话题的讨论汇总
话题: list话题: rrc话题: typedef话题: struct话题: code