Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / May 2005

Tip: Looking for answers? Try searching our database.

Functions exported in C++ and global variables;

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
xbsantos - 02 May 2005 17:20 GMT
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
Kapil Khosla [MSFT] - 02 May 2005 18:15 GMT
> Functions exported in C++ and global variables;
>
[quoted text clipped - 26 lines]
>
> 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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.