IT-Consultant: James C. Fuller > Discussion

TCLib example for Patrice

<< < (2/6) > >>

Mike Lobanovsky:

No problem. Below is the ForPatrice02 solution with the SDK version of the file. It is exactly the same as the RC version except:
* its JCF project refers to the 02 versions of source and resource files; and
* it references two more LIBs in its link stage: gdi32.lib and comctl32.lib.
Creating a solution from scratch is pretty straight forward:
* create an empty C++ solution;
* add the existing CPP file(s) to the Solution Explorer's Source Files section;
* add the existing RC file to the Solution Explorer's Resource Files section;
* if you aren't planning to edit the header files and they are appropriately #include'd in your CPP file(s), then you may omit adding them to the Header Files section of Solution Explorer; and
* if your resources (like e.g. the manifest file) are appropriately referenced in your RC file and you aren't going to edit them, then you may omit adding them to your solution.
Then just open up your batch file, select your project in the Solution Explorer, goto your PROJECT->Properties->Property Pages dialog from your main menu, and looking in your batch file's compile and link options, try to find the matching entries and settings in the Property Pages dialog's Configuration Properties->C/C++ and ->Linker options. Note however that the Property Pages options are not 100% exhaustive and there are always some compiler/linker options that you will have to add manually to the appropriate <edit...> fields in the respective entries. E.g. while you can set the /STACK: reserve[,commit] option directly in the linker settings, to the best of my knowledge there's no option for the /GsNNNN stack size parameter, which you will have to add as an extra in the Additional Options entry.

Make sure to click the Apply button if you've just changed some setting or option before you proceed to another page in the Property Pages dialog! If you don't do that then your changes will not be reflected in real time in the All Options and Command Line summaries of respective C/C++ and Linker sections of this dialog.

(James, this isn't a .SIN file, it's a .SLN file - as in "solution", not "sin"...  ;D )


I don't know what your problem might be in either one of your Visual Studios. It's a valid VS2013 solution without any Ultimate or Professional specific dependencies so it should also be usable even in the VS2013 Community mode. And if you try to open it in VS2015, then the first thing Visual Studio is gonna do will be asking you to upgrade it to the VS2015 format, which in fact will boil down to promoting its declared toolchain from v120 to v140...

[UPD] The zip below has been updated with cleaner, more precise solution project settings (see my Replies #7 and #9 below). Please re-download.

Patrice Terrier:
This one works, and creates a 13kb exe binary.  :)

Mike Lobanovsky:
Great! This is exactly how large (or in fact small) James' original executable is when generated with his batch file.

As an afterthought (a.k.a. "did you know..." a.k.a. "tip of the day"):
* you will probably be able to avoid the compile-time "deprecated" function warnings if you add the following extra macro to your Property Pages->C/C++->Preprocessor Definitions: _CRT_SECURE_NO_WARNINGS;
* even if you aren't (accustomed to) using VS solutions to compile your C++ projects, you may still find it useful to i) create a dummy solution for your project; ii) add its files to the appropriate sections in the Solution Explorer; and iii) add your existing .BAT file as a TOOLS->External Tools... facility in your VS main menu. In this way you will be able to enjoy VS' automatic highlighting, formating, and intellisense facilities for editing your source files while preserving total control over the build process via your own generic batch file. Just be sure to avoid the BUILD menu and instead, use your proprietary External Tool to create your project with. :)

Patrice Terrier:
I have already removed all the warnings  8)

Or just add this at the top of the main section

and in the
Preprocessor Definitions _UNICODE;UNICODE;%(PreprocessorDefinitions)
to get rid of the WINVER_WIN32_WINNT_VISTA invalid macro definition.
and use (long) or (int) in front of all _tsize that are affected to int.


--- Code: ---bool String::blnSuccess() {
    BOOL bRet = FALSE;
    if (this->blnSucceeded) { bRet = TRUE; }
    return bRet;
--- End code ---

Mike Lobanovsky:

--- Quote from: Patrice Terrier on January 13, 2017, 11:10:46 PM ---I have already removed all the warnings  8)
--- End quote ---

That's cool, Patrice!

* We agreed to create a valid solution, didn't we? We could define all preprocessing directly in the main CPP file through macros and pragmas but we should set the solution environmental options properly instead.
* With a view to Item 1, _CRT_SECURE_NO_WARNINGS is all right but it should be moved out of the CPP file and into Preprocessor Definitions _UNICODE;UNICODE;%(PreprocessorDefinitions).
* WINVER=_WIN32_WINNT_VISTA and _WIN32_WINNT=_WIN32_WINNT_VISTA should be left in their places with equal signs added (I did overlook them when copy-pasting though). After all, they were defined by the original author and these environmental variables may probably be still meaningful for proper linking against the library.
* C/C++->Code Generation->Runtime Library should be set to Multi-threaded (/MT) static library compilation. This will remove the DLL warnings.
* You shouldn't enforce your casts where the author has not yet had their say. Probably James or Frederick would first explain why their own parameter definitions were so lax as compared to what's expected in VC? In the meantime, the executable will perform as expected even while the remaining few warnings are still outstanding at compile time.
* I've replaced my original JCF4PT_02 submission with the new one where the above faults have been fixed. You can re-download it from my Reply #5 above.


[0] Message Index

[#] Next page

[*] Previous page

Go to full version