| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 855 人关注过本帖
标题:问一个问题, 我C好像好菜.....
只看楼主 加入收藏
kingzhui006
Rank: 1
来 自:福建
等 级:新手上路
帖 子:24
专家分:0
注 册:2009-2-25
结帖率:87.5%
收藏
 问题点数:0 回复次数:4 
问一个问题, 我C好像好菜.....
弱弱的问一下, 这样写是什么意思,
只要解释语法就好了....
#define DLL_API  extern "c" _declspec(dllexport)
2010-01-13 12:25
广陵绝唱
Rank: 10Rank: 10Rank: 10
等 级:贵宾
威 望:29
帖 子:3607
专家分:1709
注 册:2008-2-15
收藏
得分:0 
宏定义,网上搜一下,然后全部看明白,这个语句的意思你也就会明白了.
2010-01-14 11:23
指手画脚
Rank: 7Rank: 7Rank: 7
等 级:黑侠
威 望:1
帖 子:334
专家分:560
注 册:2009-12-28
收藏
得分:0 
程序代码:
Microsoft Specific
The extended attribute syntax for specifying storage-class information uses the __declspec keyword, which specifies that an instance of a given type is to be stored with a Microsoft-specific storage-class attribute listed below. Examples of other storage-class modifiers include the static and extern keywords. However, these keywords are part of the ANSI specification of the C and C++ languages, and as such are not covered by extended attribute syntax. The extended attribute syntax simplifies and standardizes Microsoft-specific extensions to the C and C++ languages.

Grammar
decl-specifier: 
__declspec ( extended-decl-modifier-seq )

extended-decl-modifier-seq: 
extended-decl-modifieropt 

extended-decl-modifier extended-decl-modifier-seq

extended-decl-modifier: 
align(#) 

allocate("segname") 

appdomain 

deprecated 

dllimport 

dllexport 

jitintrinsic

naked 

noalias 

noinline 

noreturn 

nothrow 

novtable 

process 

property({get=get_func_name|,put=put_func_name}) 

restrict 

selectany 

thread 

uuid("ComObjectGUID")

White space separates the declaration modifier sequence. Examples appear in later sections.

Extended attribute grammar supports these Microsoft-specific storage-class attributes: align, allocate, appdomain, deprecated, dllexport, dllimport, jitintrinsic, naked, noalias, noinline, noreturn, nothrow, novtable, process, restrict, selectany, and thread. It also supports these COM-object attributes: property and uuid. 

The dllexport, dllimport, naked, noalias, nothrow, property, restrict, selectany, thread, and uuid storage-class attributes are properties only of the declaration of the object or function to which they are applied. The thread attribute affects data and objects only. The naked attribute affects functions only. The dllimport and dllexport attributes affect functions, data, and objects. The property, selectany, and uuid attributes affect COM objects.

The __declspec keywords should be placed at the beginning of a simple declaration. The compiler ignores, without warning, any __declspec keywords placed after * or & and in front of the variable identifier in a declaration.

A __declspec attribute specified in the beginning of a user-defined type declaration applies to the variable of that type. For example:

  Copy Code 
__declspec(dllimport) class X {} varX;
 

In this case, the attribute applies to varX. A __declspec attribute placed after the class or struct keyword applies to the user-defined type. For example:

  Copy Code 
class __declspec(dllimport) X {};
 

In this case, the attribute applies to X.

The general guideline for using the __declspec attribute for simple declarations is as follows:

  Copy Code 
decl-specifier-seq declarator-list;
 

The decl-specifier-seq should contain, among other things, a base type (e.g. int, float, a typedef, or a class name), a storage class (e.g. static, extern), or the __declspec extension. The init-declarator-list should contain, among other things, the pointer part of declarations. For example:

  Copy Code 
__declspec(selectany) int * pi1 = 0;   //OK, selectany & int both part of decl-specifier
int __declspec(selectany) * pi2 = 0;   //OK, selectany & int both part of decl-specifier
int * __declspec(selectany) pi3 = 0;   //ERROR, selectany is not part of a declarator
 

The following code declares an integer thread local variable and initializes it with a value:

  Copy Code 
// Example of the __declspec keyword
__declspec( thread ) int tls_i = 1;
 

世界很简单 是非很复杂
有些东西是你的 但是你质疑的多了 可能就不是你的了
2010-01-14 11:50
ZTCK
Rank: 2
来 自:信宜
等 级:论坛游民
帖 子:20
专家分:39
注 册:2010-1-14
收藏
得分:0 
楼上的……我晕了……
2010-01-14 16:44
指手画脚
Rank: 7Rank: 7Rank: 7
等 级:黑侠
威 望:1
帖 子:334
专家分:560
注 册:2009-12-28
收藏
得分:0 
以下是引用ZTCK在2010-1-14 16:44:22的发言:

楼上的……我晕了……http://list.image.baidu.com/t/image_category/image_funny_files/funny_baoxiaoqiangren06.jpg
说句实话 其实我也有点儿晕 呵呵
看了半天 就明白大概意思
_declspec的作用取决于它的参数

世界很简单 是非很复杂
有些东西是你的 但是你质疑的多了 可能就不是你的了
2010-01-14 16:55
快速回复:问一个问题, 我C好像好菜.....
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.022017 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved