473,327 Members | 2,012 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

Functions exported in C++ and global variables;

Functions exported in C++ and global variables;

Hello,

I'm working with a DLL project in VISUAL C++ that exports one function with
the sentence
__declspec(dllexport). The problem is that this function returns the value
of a dll global
variable, but in fact the application that imports this functions from the
dll only see the
initial value of the global variable of the dll, but it doesn't remark
changes of value in this global
variable.

// This is an example of an exported function.
IMPORTINGDLL_API int fnProvadll(void)
{
return xavi;
}

//and the global variable in the DLL is defined like this:

int xavi=0;

What could be the problem? Please some advice from you will be useful!
Thanks all people!

Sincerely,

javitobcn
Nov 17 '05 #1
1 1358


"xbsantos" wrote:
Functions exported in C++ and global variables;

Hello,

I'm working with a DLL project in VISUAL C++ that exports one function with
the sentence
__declspec(dllexport). The problem is that this function returns the value
of a dll global
variable, but in fact the application that imports this functions from the
dll only see the
initial value of the global variable of the dll, but it doesn't remark
changes of value in this global
variable.

// This is an example of an exported function.
IMPORTINGDLL_API int fnProvadll(void)
{
return xavi;
}

//and the global variable in the DLL is defined like this:

int xavi=0;

What could be the problem? Please some advice from you will be useful!
Thanks all people!

Sincerely,

javitobcn

Where is the global variable being set. I tried setting it in the fnProvadll
function definition and dont get into this issue.
//1.cpp

int xavi = 0;

__declspec(dllexport) int fnProvadll(void)
{
xavi = 9;
return xavi;
}

//m.cpp

using namespace System;
#include <stdio.h>
__declspec(dllimport) int fnProvadll(void);

int main()
{
printf("Val is %d\n",fnProvadll());
}

cl /LD /EHsc 1.cpp
cl /clr m.cpp /link 1.lib
m.exe
I do get the correct value of global here. Can you post more code for us to
figure out what is happening here.

Thanks,
Kapil

Nov 17 '05 #2

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

Similar topics

2
by: will taubin | last post by:
i would like my program to have a config.php with passwords and other stuff. i would like to have a functions.php to hold all my functions. i would like the functions.php to include/require...
99
by: David MacQuigg | last post by:
I'm not getting any feedback on the most important benefit in my proposed "Ideas for Python 3" thread - the unification of methods and functions. Perhaps it was buried among too many other less...
76
by: Nick Coghlan | last post by:
GvR has commented that he want to get rid of the lambda keyword for Python 3.0. Getting rid of lambda seems like a worthy goal, but I'd prefer to see it dropped in favour of a different syntax,...
1
by: Bob Rock | last post by:
Hello, in the last few days I've made my first few attempts at creating mixed C++ managed-unmanaged assemblies and looking aftwerwards with ILDASM at what is visible in those assemblies from a...
1
by: XBSANTOS | last post by:
Functions exported in C++ and global variables; Hello, I'm working with a DLL project in VISUAL C++ that exports one function with the sentence __declspec(dllexport). The problem is that this...
8
by: lawrence | last post by:
I'm learning Javascript. I downloaded a script for study. Please tell me how the variable "loop" can have scope in the first function when it is altered in the second function? It is not defined...
10
by: ankisharma | last post by:
Hi all At many places I have seen that programmers pass global variables to functions in c. I am not able to figure out why they do so. need some clues on this. somewhere i heard that this...
7
by: zeecanvas | last post by:
Hi, First of all: Yes, I know global variables are bad, but I've a huge amount of legacy code, and I've to maintain it _as_is_. I'm maintaining a big program. I moved all (program-wide scope)...
1
by: metiu | last post by:
Hi all, maybe it's an old question, but I couldn't find an answer... let's say I have this kind of directory structure for project foo: /foo/includes/mod1.h (exported by mod1)...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.