#pragma section
看了别人使用了#pragma section来共享变量,今天试了下
如下添加代码
#define GLOBAL_SHARED __declspec(allocate(".Shared"))
#pragma section(".Shared",read,write,shared)
GLOBAL_SHARED int gs_nTest;
GLOBAL_SHARED char gs_caTest[];
如上定义两个变量,编译完成后,启动两个实例A和B
在A中进行赋值,可以在B中直接读到,同样在B中赋值,在A中也可以读到,很方便
另外,实验发现:
1、CString变量不可以
2、实例A和B必须是同一程序,路径不同也不可以
网上找的参考
#pragma section( "section-name" [, attributes] )
Creates a section in an .obj file. Once a section is defined, it remains valid for the remainder of the compilation. However, you must use __declspec(allocate) or nothing will be placed in the section. section-name is a required parameter that will be the name of the section. The name must not conflict with any standard section names. See /SECTION for a list of names you should not use when creating a section. attributes is an optional parameter consisting of one or more comma-separated attributes that you want to assign to the section. Possible attributes are: read
Allows read operations on data.
write
Allows write operations on data.
execute
Allows code to be executed.
shared
Shares the section among all processes that load the image.
nopage
Marks the section as not pageable; useful for Win32 device drivers.
nocache
Marks the section as not cacheable; useful for Win32 device drivers.
discard
Marks the section as discardable; useful for Win32 device drivers.
remove
Marks the section as not memory-resident; virtual device drivers (VxD) only.
If you do not specify attributes, the section will have read and write attributes. Example
In the following example, the first instruction identifies the section and its attributes. The integer j is not put into mysec because it was not declared with __declspec(allocate); j goes into the data section. The integer i does go into mysec as a result of its __declspec(allocate) storage-class attribute.
#pragma section的更多相关文章
- 实例详解——编译器命令#pragma section作用于函数时作用域是否覆盖到其子函数
在之前的博客[链接脚本(Linker Script)应用实例(一)使用copy table将函数载入到RAM中运行]中,我们第一步使用#pragma section命令将PFlashProgram函数 ...
- 小侃#pragma
#pragma是一个编译器指令. ================================================================ #pragma comment(li ...
- #pragma init_seg
先进后出原则,最先初始化的最后析构! 1.C++中全局对象.变量的构造函数调用顺序是跟声明有一定关系的,即在同一个文件中先声明的先调用.对于不同文件中的全局对象.变量,它们的构造函数调用顺序是未定义的 ...
- #pragma预处理命令详解
#pragma预处理命令 #pragma可以说是C++中最复杂的预处理指令了,下面是最常用的几个#pragma指令: #pragma comment(lib,"XXX.lib") ...
- #pragma预处理命令【转】
原文 : http://www.cnblogs.com/qinfengxiaoyue/archive/2012/06/05/2535524.html #pragma可以说是C++中最复杂的预处理指令了 ...
- 【VS开发】#pragma预处理命令
#pragma预处理命令 #pragma可以说是C++中最复杂的预处理指令了,下面是最常用的几个#pragma指令: #pragma comment(lib,"XXX.lib") ...
- 深入理解Objective-C:Category
摘要 无论一个类设计的多么完美,在未来的需求演进中,都有可能会碰到一些无法预测的情况.那怎么扩展已有的类呢?一般而言,继承和组合是不错的选择.但是在Objective-C 2.0中,又提供了categ ...
- 搭建基于 STM32 和 rt-thread 的开发平台
我们需要平台 如果说,SharePoint 的价值之一在于提供了几乎开箱即用的 innovation 环境,那么,智能设备的开发平台也一样.不必每次都从头开始,所以需要固定的工作室和开发平台作为创新的 ...
- RFC-2068-http
本文档规定了互联网社区的标准组协议,并需要讨论和建议以便更加完善.请参考 “互联网官方协议标准”(STD 1)来了解本协议的标准化状态.本协议不限流传发布. 版权声明 Copyright (C) Th ...
随机推荐
- CODEVS 3279 奶牛的健美操
3279 奶牛健美操 USACO 时间限制: 2 s 空间限制: 256000 KB 题目等级 : 钻石 Diamond 题目描述 Description Farmer John为了保持奶牛们的 ...
- hdu5353 Average(模拟)
转载请注明出处: http://www.cnblogs.com/fraud/ ——by fraud Average Time Limit: 4000/2000 MS (Java/Ot ...
- 一个经试用效果非常不错的数据库连接池--JAVA
前言: 虽说现在许多企业级的应用服务器均自己带有数据库连接池功能,就连 Tomcat 也支持了这种功能.然而在许多时候,我们还是要使用数据库连接池,如:访问数据库的 Java 桌面应用程序等.这个数据 ...
- Java中通过递归调用删除文件夹下所有文件
摘自 : http://blog.sina.com.cn/s/blog_79333b2c0100xiu4.html import java.io.File; public class FileTest ...
- 免费馅饼(HDU 1176 DP)
免费馅饼 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submis ...
- IOS 面试 --- 网络部分
网络部分 3 做过的项目是否涉及网络访问功能,使用什么对象完成网络功能? 答案:ASIHTTPRequest与NSURLConnection 4 简单介绍下NSURLConnection类及+ sen ...
- 转载收藏之用 - 微信公众平台开发教程(七):解决用户上下文(Session)问题
从这篇文章中我们已经了解了微信公众平台消息传递的方式,这种方式有一个先天的缺陷:不同用户的请求都来自同一个微信服务器,这使得常规的Session无法使用(始终面对同一个请求对象,况且还有对方服务器Co ...
- js django 数据互动
后台传输到客户端的数据怎么跟js进行互动 eval("("+{{data|safe}}+")") 获取到的数据可以直接使用 eval 有时候会存在编码问题所以推 ...
- hihoCoder 1041 国庆出游 (DFS)
题意: 小Hi和小Ho准备国庆期间去A国旅游.A国的城际交通比较有特色:它共有n座城市(编号1-n):城市之间恰好有n-1条公路相连,形成一个树形公路网.小Hi计划从A国首都(1号城市)出发,自驾遍历 ...
- 【转】P2P之UDP穿透NAT的原理与实现(附源代码)
作者:shootingstars (有容乃大,无欲则刚) 日期:2004-5-25 出处:P2P中国(PPcn.net) P2P 之 UDP穿透NAT的原理与实现(附源代码)原创:shootings ...