473,757 Members | 2,066 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

pragma value for shared variables

All,

I came to know that, we can define #pragma variables to share values
between the processes.

#pragma data_seg(".shar ed")
var1
variable2
#pragma data_seg()

Is there are any advantages/disadv. over using file mapping. Can any
one send me detials or any link which compares or explains about these
shared variables

Thanks
Radha G

Sep 13 '07 #1
3 3799
On 2007-09-13 12:30, Oops-c++ wrote:
All,

I came to know that, we can define #pragma variables to share values
between the processes.

#pragma data_seg(".shar ed")
var1
variable2
#pragma data_seg()

Is there are any advantages/disadv. over using file mapping. Can any
one send me detials or any link which compares or explains about these
shared variables
A problem with all progma directives is that most or perhaps all of them
are implementation dependent. That means that compiling the same code
with another compiler or even just with another version of the same
compiler might give different results. IIRC a compiler should just
ignore any pragmas that it does not understand.

There are an number of different ways to share data between processes,
which one you should use depends on a lot of things, like which platform
your program runs on, how much data you need to share, and in which
manner you need to share it. For better advice explain your needs in a
group discussing your platform. The FAQ have some suggestions of groups:
http://www.parashift.com/c++-faq-lit...t.html#faq-5.9

--
Erik Wikström
Sep 13 '07 #2
On Sep 13, 4:30 pm, Erik Wikström <Erik-wikst...@telia. comwrote:
On 2007-09-13 12:30, Oops-c++ wrote:
All,
I came to know that, we can define #pragma variables to share values
between the processes.
#pragma data_seg(".shar ed")
var1
variable2
#pragma data_seg()
Is there are any advantages/disadv. over using file mapping. Can any
one send me detials or any link which compares or explains about these
shared variables

A problem with all progma directives is that most or perhaps all of them
are implementation dependent. That means that compiling the same code
with another compiler or even just with another version of the same
compiler might give different results. IIRC a compiler should just
ignore any pragmas that it does not understand.

There are an number of different ways to share data between processes,
which one you should use depends on a lot of things, like which platform
your program runs on, how much data you need to share, and in which
manner you need to share it. For better advice explain your needs in a
group discussing your platform. The FAQ have some suggestions of groups:http://www.parashift.com/c++-faq-lit...t.html#faq-5.9

--
Erik Wikström
ThanQ Erik. I am working on Windows and *NIX
environments(Li nux,AIX,solaris ,HP-UX). I am using shared memory(POSIX-
on linux,File mapping object on windows) for IPC. The data size that
shared between the the process is 1-2 kB. Is there any other better
way to have IPC between processes? Do you know the exclusive IPC
group? Please send me the details.

Thanks
Radha. G.

Sep 14 '07 #3
Oops-c++ wrote:
>
ThanQ Erik. I am working on Windows and *NIX
environments(Li nux,AIX,solaris ,HP-UX). I am using shared memory(POSIX-
on linux,File mapping object on windows) for IPC. The data size that
shared between the the process is 1-2 kB. Is there any other better
way to have IPC between processes? Do you know the exclusive IPC
group? Please send me the details.
Forget pragmas and use the standard shared memory APIs on you platforms.

--
Ian Collins.
Sep 14 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3974
by: ryang | last post by:
I am trying to understand how to work with Unicode in Perl. I have read the relevant man pages (perluniintro, perlunicode, etc.) and have written severl scripts to test/verifiy my understanding. However, I created a script that has unexpected output. The script is below and it contains some UTF-8 encoded characters which represent all five Spanish accented vowels plus the enye (n with a tilde over it) in upper and lower case. I hope...
20
4850
by: Glenn Venzke | last post by:
I'm writing a class with a method that will accept 1 of 3 items listed in an enum. Is it possible to pass the item name without the enum name in your calling statement? EXAMPLE: public enum EnumName FirstValue = 1 SecondValue = 2 ThirdValue = 3
8
1270
by: gemel | last post by:
I have been reading sime material in .NET that throws some doubt on my understanding of shared procedures. With regard to object programming I assumed that variables declared within a class were private to the class, each object would have access to it's ver own copy of that variable. With regard to the methods defined for a class, I assumed that these are shared among all objects of the class, the code acting on the instances own copy...
7
1277
by: Marco | last post by:
The subject pretty much says it all. I need to create a form like the msgbox that returns a value, how would I go about doing this?
5
4394
by: Confused ! | last post by:
I am writing an ASP.NET application and I want to use shared members on the data layer to retreive information from the SQL Server. If I declare a Function to be Shared, how will this affect things in a multi user environment. In other words, are my shared classes for the want of a better word. "Instantiated" for each user. Hope this makes sense ! --
15
3759
by: muttaa | last post by:
Hello all, I'm a beginner in C...May i like to know the difference between a #pragma and a #define.... Also,yet i'm unclear what a pragma is all about as i can find topics on it only in high-standard books...
2
10197
Semprini
by: Semprini | last post by:
Hiya, I'm programming a dll in VC6 which is uses windows hooks (WH_GETMESSAGE). So I have a HOOKPROC which is called whenever messages are sent the the monitored hwnd I have a shared data segment like so: #pragma data_seg("SHARED") ...variables in here #pragma data_seg() #pragma comment(linker, "/section:SHARED,RWS")
0
977
by: netkadirisani | last post by:
Hi, i built a dll (used vb.net) that has some shared variables. the basic idea of using the shared variables is to read some values from the database and save them in the shared variables during the first access of dll and use them then on thus avoiding any more database hits. when i use the dll on my machine, it works perfect. i.e., it reads the values from database, saves them to shared variables on one time basis. but when i installed the...
0
10693
debasisdas
by: debasisdas | last post by:
PRAGMA:-Signifies that the statement is a pragma (compiler directive). Pragmas are processed at compile time, not at run time. They pass information to the compiler. A pragma is an instruction to the Oracle compiler that tells it to do something. In this case you are telling Oracle to associate an error that you choose to a variable that you choose. This pragma must go in the declarative section of your block. Types of PRAGMA...
0
9487
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9297
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10069
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9884
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9735
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6556
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5324
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3395
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2697
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.