C宏 [英] C macro

查看:84
本文介绍了C宏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



在我看来,我有一个有趣的问题。我有两个写一个

宏,它告诉我们传递给它的

类型的参数

即int,short,long,signed ,unsigned..etc

喜欢


typedef T unsigned int

value(T)


我必须printf()T是什么样的价值......


问候

Gurminder

Hi,
I have an intersting quesiton in my view. I have two write a
macro which tell what is the
type of argument being passed to it
i.e int, short, long, signed , unsigned..etc
like

typedef T unsigned int
value(T)

I have to printf() what kind of value T is...

Regards
Gurminder

推荐答案

sunny说:
sunny said:



我有一个有趣的问题在我看来。
Hi,
I have an intersting quesiton in my view.



一个有趣的问题?很酷。

An interesting question? Cool.


我有两个写一个宏来告诉你传递给它的

类型的参数,即int,short,

long,signed,unsigned..etc like


typedef T unsigned int

value(T)


我必须printf()T是什么样的价值...
I have two write a macro which tell what is the
type of argument being passed to it i.e int, short,
long, signed , unsigned..etc like

typedef T unsigned int
value(T)

I have to printf() what kind of value T is...



好​​的,明白了。现在,你说你有一个有趣的问题,但我不会看到一个问题。


-

Richard Heathfield

Usenet是一个奇怪的地方 - dmr 29/7/1999
http://www.cpax.org.uk

电子邮件:rjh在上面的域名(但显然放弃了www)

Okay, understood. Now, you said you had an interesting question, but I don''t
see a question.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)




晴天写道:

sunny wrote:



我认为我有一个有趣的问题。我有两个写一个

宏,它告诉我们传递给它的

类型的参数

即int,short,long,signed ,unsigned..etc

喜欢


typedef T unsigned int

value(T)


我必须printf()T是什么样的价值...
Hi,
I have an intersting quesiton in my view. I have two write a
macro which tell what is the
type of argument being passed to it
i.e int, short, long, signed , unsigned..etc
like

typedef T unsigned int
value(T)

I have to printf() what kind of value T is...



这是一个挑战。 Straight C在编译时或运行时都没有任何类型查询

函数,所以只知道类型

不是很有帮助。


有一个相当贫瘠的sizeof()函数,它会告诉你如何占用很多字节的b / b
,但这并不是很有用,除非你假设

只会传入类似整数的类型。即便如此,要知道T是签名还是未签名,确实有点棘手。


也许你可以更详细地复述你的问题。


That''s a bit of a challenge. Straight C doesnt have any type-inquiry
function at either compile-time or run-time, so just knowing the type
isnt of much help.

There is the rather barren sizeof() function, which will tell you how
many bytes T occupies, but that isnt very helpful, unless you assume
only integer-like types are going to be passed in. Even then it''s
going to be a bit tricky to figure out if T is signed or unsigned.

Perhaps you could retell your question, in a bit more detail.


sunny(在 11 ******************** **@75g2000cwc.googlegroups.c om )说:


|

|在我看来,我有一个有趣的问题。我有两个

|写一个宏,告诉什么是

|传递给它的参数类型

|即int,short,long,signed,unsigned..etc

|喜欢

|

| typedef T unsigned int

|价值(T)

|

|我必须printf()T是什么样的价值......


确实是一项有趣的任务。你的解决方案何时到期?


-

Morris Dovey

DeSoto Solar

DeSoto,爱荷华州美国
http://www.iedu.com/DeSoto
sunny (in 11**********************@75g2000cwc.googlegroups.c om) said:

| Hi,
| I have an intersting quesiton in my view. I have two
| write a macro which tell what is the
| type of argument being passed to it
| i.e int, short, long, signed , unsigned..etc
| like
|
| typedef T unsigned int
| value(T)
|
| I have to printf() what kind of value T is...

An interesting assignment indeed. When is your solution due?

--
Morris Dovey
DeSoto Solar
DeSoto, Iowa USA
http://www.iedu.com/DeSoto


这篇关于C宏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆