|
Assuming that static specifies that m_foo is not visible from outside stdafx.h , what if you remove the static qualifier?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I need to make it "static" in order to keep from getting fatal LNK1169 error "one or more multiply defined symbols found"
|
|
|
|
|
werpa wrote: error "one or more multiply defined symbols found"
this is normally solved using extern, not static, no ?
my bad, David got it right. you must use exclusive statement macros
|
|
|
|
|
werpa wrote: I need to make it "static" in order to keep from getting fatal LNK1169 error "one or more multiply defined symbols found"
Something is amiss with your stdafx.h file. It should resemble:
#if !defined(STDAFX_H)
#define AFX_STDAFX_H
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#define _WIN32_WINNT 0x0500
int m_foo;
#endif
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Thanks for your good thoughts.
I made these changes but still need "static" to keep from getting LNK1169.
|
|
|
|
|
werpa wrote: I made these changes but still need "static" to keep from getting LNK1169.
You are simply addressing the symptom and not the underlying cause. Find all declarations of m_foo . The one in stdafx.h should be declared as:
int m_foo; and all others should be declared as:
extern int m_foo; You'll find that Nemanja's suggestion is a bit cleaner, though, as it only requires changing two files.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
That worked great to get rid of the LNK1169. (I put it the extern everywhere!) Now, however, it comes back if I set the value or query it. As long as I don't use the value in the module the error stays away. The minute I add it to the module, I get it back.
|
|
|
|
|
Isn't that reversed?
Shouldn't the extern declaration be in the header and ONE "int m_foo;" instance be in a cpp
module somewhere?
Mark
"Great job, team. Head back to base for debriefing and cocktails."
(Spottswoode "Team America")
|
|
|
|
|
nope.
by doing what Nemanja suggested, every cpp file actually includes the extern declaration (so, don't define the variable, and assume that it is defined elsewhere), and stdafx.cpp is the exception, by actually declaring the global variable.
oh my !
forget it
|
|
|
|
|
Goofball
"Great job, team. Head back to base for debriefing and cocktails."
(Spottswoode "Team America")
|
|
|
|
|
I tried it both ways and it worked the same. Since the header file looked like this, the variable was only declared once.
Like I said, Nemanja's way is cleaner as it only involves two changes, rather than multiple changes depending on how many places use the "global" variable.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
OK I assumed stdafx was used in the normal way - as a PCH included in every module. Which
would make a separate instance for every module, right?
"Great job, team. Head back to base for debriefing and cocktails."
(Spottswoode "Team America")
|
|
|
|
|
This will produce link errors because every .CPP file will have a definition of the variable m_foo .
Steve
|
|
|
|
|
Stephen Hewitt wrote: This will produce link errors...
It doesn't.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Are we talking about the same thing? It seems it does[^].
Steve
|
|
|
|
|
There's probably no link error because the scope of each m_foo is contained to each cpp module.
The real problem that I see is that it's not a single global variable.
Mark
"If you can dodge a wrench, you can dodge a ball."
|
|
|
|
|
In stdafx.h:
extern int foo;
And, in stdafx.cpp:
int foo;
|
|
|
|
|
In your "StdAfx.h":
extern int m_foo;
The extern makes it a declaration and not a definition.
In one .CPP file somewhere (you could use the "StdAfx.cpp"):
int m_foo;
This is the definition.
Steve
|
|
|
|
|
Thank you for your great comments. I have made the changes with the results that I originally asked for.
|
|
|
|
|
Hi,
//i have this:
char **Temp;
Temp = (char **)malloc(sizeof(char *));
*Temp = (char *)malloc(MAX_LIST);
//ok... now i want free the allocate memory...with..
free(Temp); <== Ok This work
free(*Temp); <== this NOT work
have you got an idea???
thanks a lot...
Raiz82
|
|
|
|
|
revert the order...
free(*Temp);
free(Temp);
btw, are you coding in C or C++ ? because, if C++, then you'd better use new/delete (or new[]/delete[])
|
|
|
|
|
i use C++,
but i had reverted the order too.... but don't work...
this is the complete code of this section...
char **Temp;
Temp = (char **)malloc(sizeof(char *));
*Temp = (char *)malloc(MAX_LIST);
DWORD size = MAX_LIST;
CString sTemp,sTemp2;
if (RegQueryValueEx(pParentWnd->m_ListKey, RSS_KEY,0,NULL,(unsigned char *)*Temp,&size) == ERROR_SUCCESS)
{
//Temp[size] = '\0';
while(**Temp != '\0')
{
sTemp = strsepRss(Temp,';');
m_cRss1Combo.AddString(sTemp);
m_cRss2Combo.AddString(sTemp);
}
m_cRss1Combo.SetCurSel(0);
m_cRss2Combo.SetCurSel(1);
}
else
{
m_cRss1Combo.AddString(ECHO_LINK);
m_cRss2Combo.AddString(ECHO_LINK);
m_cRss1Combo.SetCurSel(0);
m_cRss2Combo.SetCurSel(0);
}
//posiziona i due combo box sul rss precedentemente salvato
if((m_cRss1Combo.FindStringExact(-1,pParentWnd->m_sRss1)) != -1)
m_cRss1Combo.SetCurSel(m_cRss1Combo.FindStringExact(-1,pParentWnd->m_sRss1));
if((m_cRss2Combo.FindStringExact(-1,pParentWnd->m_sRss2)) != -1)
m_cRss2Combo.SetCurSel(m_cRss2Combo.FindStringExact(-1,pParentWnd->m_sRss2));
UpdateString(pParentWnd->m_iVisualizationControl);
free(*Temp);//giulio
free(Temp);
but i don't understand....
Help me!!! ehhehehehehehhe
bye
|
|
|
|
|
Ing.Raiz82 wrote: if (RegQueryValueEx(pParentWnd->m_ListKey, RSS_KEY,0,NULL,(unsigned char *)*Temp,&size) == ERROR_SUCCESS)
Have you tried:
BYTE Temp[1024];
DWORD size = sizeof(Temp);
if (RegQueryValueEx(pParentWnd->m_ListKey, RSS_KEY, 0, NULL, Temp, &size) == ERROR_SUCCESS)
...
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
thanks for the interest.... but... if i change this....
/*
char **Temp;
Temp = (char **)malloc(sizeof(char *));
*Temp = (char *)malloc(MAX_LIST);
DWORD size = MAX_LIST;
*/
BYTE Temp[1024];
DWORD size = sizeof(Temp);
CString sTemp,sTemp2;
if (RegQueryValueEx(pParentWnd->m_ListKey, RSS_KEY,0,NULL,Temp,&size) == ERROR_SUCCESS)
{
//Temp[size] = '\0';
while(**Temp != '\0')
{
sTemp = strsepRss(Temp,';'); <==
////////////////Problem////////////////////
i have problem here because strsepRss ask char ** stringp
//////////////////////////////////////////
m_cRss1Combo.AddString(sTemp);
m_cRss2Combo.AddString(sTemp);
}
m_cRss1Combo.SetCurSel(0);
m_cRss2Combo.SetCurSel(1);
}
else
{
m_cRss1Combo.AddString(ECHO_LINK);
m_cRss2Combo.AddString(ECHO_LINK);
m_cRss1Combo.SetCurSel(0);
m_cRss2Combo.SetCurSel(0);
}
//posiziona i due combo box sul rss precedentemente salvato
if((m_cRss1Combo.FindStringExact(-1,pParentWnd->m_sRss1)) != -1)
m_cRss1Combo.SetCurSel(m_cRss1Combo.FindStringExact(-1,pParentWnd->m_sRss1));
if((m_cRss2Combo.FindStringExact(-1,pParentWnd->m_sRss2)) != -1)
m_cRss2Combo.SetCurSel(m_cRss2Combo.FindStringExact(-1,pParentWnd->m_sRss2));
UpdateString(pParentWnd->m_iVisualizationControl);
//free(*Temp);//giulio
free(Temp);
sorry but i'm a novice of c++...
thanks still...
Giulio
|
|
|
|
|
Ing.Raiz82 wrote: i have problem here because strsepRss ask char ** stringp
So just use strtok() .
Or, since you are using MFC, use a CString object, and AfxExtractSubString() .
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|