Monday, December 14, 2009

Array as a function parameter...

This can be kinda tricky at first, but really it is just a matter of leveraging the convergence of the zero element of an array and a pointer of the same type.

so you have
int myInts[] = {1,2,3,4,5}
that needs to be passed into a function

so you just prototype the function:
foo(int* input);
and to use it just pass in the array:
foo(myInts);

Linker Tools Warning(s)

LNK4221:
You get this warning when you add resources to a static library. Okay, but what does that really mean?

LNK2001: unresolved external symbol, "symbol"
We have all seen this one, first thing I always check is the vcproj to ensure I told the linker to use someLib.lib; seems obvious, but it is easy to forget. In fact, I just did this very thing. And that simple mistake is captured here in this blog entry in hopes you will not have to make the mistake as often; don't fool yourself - we'll all still forget it sometimes....

LNK2005: symbol already defined in object
Just ran into this again... and #6 of MSDN's fixes is to add /FORCE:MULTIPLE to the linker comand line options, and make sure that uuid.lib is the first library referenced. but it did not help so my issue was something else.

Friday, December 11, 2009

Packaging libraries

So you have some code that is/was/should be a packaged as a library to isolate and encapsulate it... now it may have been directly compiled in a previous project, but now you need to isolate it.
First off, take careful examination of the code that was compiled in the previous project as it will most likely be benchmark for features. And if the new lib is not compiling the same set of files it will not be equivalent to the directly compiled code.

Chipset reviews

AnandTech does some very nice reviews

Intel Core i7

AMD Phenom II X4 945/955

Warning suppression

Maybe you are leveraging an older library (in compiler terms) that is using deprecated APIs and is causing warnings and the warnings suggest suppression using _CRT_SERCURE_NO_WARNINGS and instructs you to see online for info...

Well if you want to use this simply go into the vcproj C/C++ settings Pre-processor and add _CRT_SECRE_NO_WARNINGS to the list. Caveat, this is a broad stroke and should only be used if that code is segregated in its own vcproj and will not be actively developed. Code under active development should just adapt to remove the warnings.

Warning by warning suppression:
directly in the code it is possible to suppress individual or blocks of warnings like this,
#pragma warning (disable: )
code generating the warning
#pragma warning (default: )
the "warning#" would be the same number in both statements.
There is more than one way to do this, but that exploration is left as an exercise to the reader...

Wednesday, December 9, 2009

GLOSSARY OF TERMS, ACRONYMS, AND ABBREVIATIONS

VS = VisualStudio, may be followed by a version/year, i.e. VS2008
vcproj = VisualStudio project file
UM = user mode
KM = kernel mode

Precompiled Headers (PCH)

Having trouble with PCHs?


A couple common areas are:


"fatal error c1083: cannot open precompiled header file:

In your vcproj Configuration Settings>C/C++>PrecompiledHeaders you are using the option "Use Precompiled Header (/Yu)" your PCH may have never been created and you should change the option to "Create Precompiled Header (/Yc)"

Now at this point the PCH is being created with each build.
And doing this in a release build configuration may lead to
C4727 warnings, which occur when multiple files are generating PCHs (/Yc)
so you have to go through each file noted by the compiler and switch back to (/Yu)
UPDATE****
in the default configuration you will have stdafx.h & stdafx.cpp (this file is the only one that should have the /Yc option)