|
|
You can ALWAYS ignore this warning.
You usually can't simply remove the DLLs from your list. They are still needed in the initial link pass and will generate a fatal error if not there.
The solution is to add "/IGNORE:4089" to the "Command Line" link options.
|
|
|
|
|
The linker is saying that you included the import libs for those three DLLs in your link options, however your code does not call anything in those DLLs. It is harmless, but the correct way to remove the warning is to remove those LIBs from the linker options (since they are unneeded anyway).
--Mike--
If it doesn't move and it should: WD-40. If it moves and it shouldn't: duct tape.
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
|
VirtualAlloc allows you to reserve memory pages without committing physical memory. It is useful for writing allocators where the following conditions are met:
- the memory needs to be contiguous OR you must be able to have that memory available
- the maximum size is known in advance
- the maximum size is fairly large
- the minimum size is relatively small
- the growth of the data to the maximum size is not quick or guaranteed (if guaranteed, and you don't want to use the heap, use GlobalAlloc.)
|
|
|
|
|
|
That is about right. VA/VF were never intended for general allocations.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Short answer; yes.
Long answer; if you examine your needs, it is very unlikely you'd need VirtualAlloc. GlobalAlloc will usually work fine for large, simple (i.e. not classes/structs requiring constructors/destructors) allocations.
Note: Large means megabytes.
Also note that you could overload new for the classes in question.
Note concerning performance. Doing lots of new's/delete's can be extremely slow. Before leaping to replace it, examine your basic algorithms. In one case, a fellow worker had created a class which created hundreds of other classes which created hundreds of other classes. It took a while to allocate everything and over 40 seconds to destruct the mess (which caused the service to time out). By simple changing a few things, I reduced this to a few seconds. By changing the core algorithm, it could have been reduced to a few dozen milliseconds, all still using new/delete.
|
|
|
|
|
Another thing VA/VF allows you to do is reserve large portions of the virtual address space without actually creating the pages. Thus you can allocate 300MB of memory and create the pages manually as you need more of this block of memory. This reduces the stress on the page management system and can improve performance.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Well, without knowing much of anything about VirtualAlloc I can tell you that new does two things automatically for you:
- Allocates just the needed block of memory for your object (or array of objects) in the heap.
- Calls the object's constructor.
The "VirtualAlloc function reserves or commits a region of pages in the virtual address space of the calling process." You have to pass the amount of memory explicitly and no constructor is called.
Regards,
Alvaro
Well done is better than well said. -- Benjamin Franklin
(I actually prefer medium-well.)
|
|
|
|
|
Can anyone help me to get the CPU usage by PDH functions?
Thanks in advance,
Dudi
|
|
|
|
|
How can I convert a string (char* ) to a integer or a float with error checking?
I want to convert a string to a integer or a float:
<br />
"1" --> int 1<br />
If the string is something like that "%"&"/ssdd" I want to know that --> ERROR!
Daniel
---------------------------
Never change a running system!
|
|
|
|
|
static _Convert ConvertLong (
const char *pszValue, long *plValue)
{
errno = 0;
char *pszEnd = NULL;
long lReturn = strtol (pszValue, &pszEnd, 10);
if (pszEnd)
{
while (isspace (*pszEnd))
pszEnd++;
if (pszValue == pszEnd || *pszEnd != 0)
return Convert_Invalid;
}
if (errno == ERANGE)
{
if (lReturn < 0)
return Convert_Underflow;
else
return Convert_Overflow;
}
*plValue = lReturn;
return Convert_Ok;
}
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Thanks !!!
Daniel
---------------------------
Never change a running system!
|
|
|
|
|
Here's some old code of mine that checks if a string value is numeric according to how you need it. For example, if you don't want it to be negative, you pass the Unsigned flag; if it can have a decimal point, you pass it the Decimal flag; etc. Notice that it assumes that a decimal point is a dot.
enum NumericFlag
{
Unsigned,
Signed,
Decimal,
SignedDecimal
};
bool IsNumeric(const char* szValue, NumericFlag flag ) const
{
assert(szValue);
int nLen = strlen(szValue);
for (int iPos = 0, nDecimalPos = -1; iPos < nLen; iPos++)
{
char c = szValue[iPos];
if (isdigit(c))
continue;
if (c == '-' && iPos == 0 && (flag & Signed))
continue;
if (c == '.' && nDecimalPos < 0 && (flag & Decimal))
{
nDecimalPos = iPos;
continue;
}
return false;
}
return !!nLen;
}
Regards,
Alvaro
Well done is better than well said. -- Benjamin Franklin
(I actually prefer medium-well.)
|
|
|
|
|
Thanks !!!
Daniel
---------------------------
Never change a running system!
|
|
|
|
|
I was about to suggest VarI4FromStr, but I see you're doing char* and not wchar_t* .
--
Only in a world this sh*tty could you even try to say these were innocent people and keep a straight face.
|
|
|
|
|
Thanks!!!
Daniel
---------------------------
Never change a running system!
|
|
|
|
|
Hi,
GetTextExtentExPoint and methods like that only work fine with fotns that have no escapement..., How can I get that size for a 90º rotated font ?
Is there any method, trick or whatever to do that ? ( swaping the values is not good enoug some pixels of differences).
Greetings
Braulio
|
|
|
|
|
I'm not sure this is what you need, but the function below tells you how many pixels are taken up by a piece of text when it's displayed on a window using a given font. It's taken out of my CAMSWnd article here[^] on CP.
int CAMSWnd::GetTextExtent(CWnd* pWnd, const CString& strText, CFont* pFont )
{
ASSERT(IsWindow(pWnd->GetSafeHwnd()));
int nExtent = 0;
int nLen = strText.GetLength();
if (nLen)
{
TEXTMETRIC tm;
CDC* pDC = pWnd->GetDC();
CFont* pFontOld = pDC->SelectObject(pFont ? pFont : pWnd->GetFont());
pDC->GetTextMetrics(&tm);
CSize size = pDC->GetTextExtent(strText, nLen);
nExtent = size.cx + tm.tmAveCharWidth;
pDC->SelectObject(pFontOld);
pWnd->ReleaseDC(pDC);
}
return nExtent;
}
Regards,
Alvaro
Well done is better than well said. -- Benjamin Franklin
(I actually prefer medium-well.)
|
|
|
|
|
I need assistance with the following code for factorials. The program is outputting incorrect answers.
// DESCRIPTION
// This program is designed to read in non-negative integers n
// and to output the value of n! = n(n-1)(n-2)...(3)(2)(1).
// Note 0! is defined as 1.
// The program should continue to read in and process new
// values of n until:
//
// 1) The value of the previous n! exceeds MAXFACT
// or
// 2) A total of MAXCOUNT input values have been processed.
//
// WARNINGS
// This program has some syntax errors and some semantic errors
// User must not enter data less than 0 or large numbers
//
#include <iostream.h>
#include <stdlib.h>
using std::cout;
using std::cin;
using std::endl;
//Place any function prototypes here:
void factorial (int n);
const int MAXCOUNT = 4;
const int MAXFACT = 10000;
int main()
{
bool done = false; //i.e. not done yet
int n, counter=0;
unsigned int n_fact = 0;
while ((counter < MAXCOUNT) || (!done))
{
cout << "Enter a non-negative integer:";
cin >> n;
//compute n factorial and display the result
factorial(n);
cout << "The value of " << n << "! is " <<fact(n) <<="" endl;
="" if="" (n_fact=""> MAXFACT) //catch large factorial
done = true;
counter++; //count this iteration
}
//upon loop exit, one of the following must be true:
//counter reached MAXCOUNT or done (due to large factorial)
system("PAUSE");
return 0;
}
void factorial(int n)
{ //compute n! by multiplying together 1, 2, 3, ..., n
int counter;
unsigned int fact=0;
cout << "The value of n received is:" << n << endl;
cout << "At the start of the loop, fact is: " << fact << endl;
for (counter = n; counter > 0; counter--) {
fact *=counter;
return fact;
}
cout << "The calculated factorial is " << fact << "\n";
}
|
|
|
|
|
for (counter = n; counter > 0; counter--) {
fact *=counter;
return fact; // I think this is your problem
}
also if n > 12, then "unsigned int fact=0;" should realy be a double or something
|
|
|
|
|
The code makes it look like it would always return 0:
unsigned int fact=0;
should be
unsigned in fact=1;
|
|
|
|
|
The code does return 0 all of the time and I am having trouble grasping how to return the value obtained in the factorial function to the main function. Any advice?
|
|
|
|
|
I am a beginner and I am trying to write a program that takes a five digit inputed value and adds the digits together. I am trying to use a for loop to do this but I am having trouble. Please help.
|
|
|
|