This Blog is first of all memos for me!! From time to time I get exposed to new and cool stuff for developers and architects ,most of the time its a solution for a problem or tips or tricks, so, I would like to track my memos and share it with you, it can save your time and nervous, I hope you will enjoy it - by Yaniv Tzanany.
Search This Blog
Showing posts with label CPP. Show all posts
Showing posts with label CPP. Show all posts
Tuesday, February 28, 2023
Wednesday, March 9, 2016
Sunday, November 29, 2015
Symas Lightning MDB (LMDB) -
this cache very useful for multi process and multi thread environment.
Symas Lightning MDB (aka Lightning Database, LMDB):
worth to try in case you need key-value cached
yaniv tzanany
Symas Lightning MDB (aka Lightning Database, LMDB):
worth to try in case you need key-value cached
yaniv tzanany
Thursday, November 19, 2015
VC++ and the Web Technology
so you want to send an email from MFC ?? parse JSON ??
Json - JsonCpp compile and work under VC++ 12.
SendEmail - CSMTPConnection Old MFC class newer version could be find here , you can send email with libcurl as well .
WebAccess - post/get ftp - the libcurl also compiled on VC++ 12.
MD5 - Example C Program: Creating an MD5 Hash from File Content
on don't forget the regular web classes in MFC - via CInternetSession and CHttpConnection
enjoy
Yaniv Tzanany
notes about jsoncpp
parsing-quoted-strings-in json
Json - JsonCpp compile and work under VC++ 12.
SendEmail - CSMTPConnection Old MFC class newer version could be find here , you can send email with libcurl as well .
WebAccess - post/get ftp - the libcurl also compiled on VC++ 12.
MD5 - Example C Program: Creating an MD5 Hash from File Content
on don't forget the regular web classes in MFC - via CInternetSession and CHttpConnection
enjoy
Yaniv Tzanany
notes about jsoncpp
parsing-quoted-strings-in json
Thursday, October 29, 2015
Wednesday, October 14, 2015
Tuesday, March 25, 2014
Monday, February 24, 2014
CCache - speed C++ compiler output
ccache is a compiler cache. It speeds up recompilation by caching previous compilations and detecting when the same compilation is being done again. Supported languages are C, C++, Objective-C and Objective-C++.
to make it work on aix with xlC_r compiler , i used the next steps:
i download the sources and compile them on aix via g++ compiler
i copied the output ccache program into my build machine.
i set the next environment to make support xlC_r compiler:
export CCACHE_EXTENSION=i (this tell the compiler to generate preprocessor file with i extension)
helper settings FYI:
export CCACHE_DISABLE=1 (to avoid using ccache)
export CCACHE_LOGFILE=/yaniv/ccachelog.log (to see ccache log)
enjoy
Yaniv Tzanany
to make it work on aix with xlC_r compiler , i used the next steps:
i download the sources and compile them on aix via g++ compiler
i copied the output ccache program into my build machine.
i set the next environment to make support xlC_r compiler:
export CCACHE_EXTENSION=i (this tell the compiler to generate preprocessor file with i extension)
helper settings FYI:
export CCACHE_DISABLE=1 (to avoid using ccache)
export CCACHE_LOGFILE=/yaniv/ccachelog.log (to see ccache log)
enjoy
Yaniv Tzanany
Thursday, January 23, 2014
Tuesday, December 17, 2013
How to list compiler predefined macros
C/C++ tip: How to list compiler predefined macros | Nadeau Software: " How to list compiler predefined macros"
for Microsoft VS2013:
http://msdn.microsoft.com/en-us/library/b0084kay.aspx
for Microsoft VS2013:
http://msdn.microsoft.com/en-us/library/b0084kay.aspx
Monday, December 16, 2013
C++ migrating to Visual Studio 2012/13 from VC6
Read here
Lessons learned migrating to Visual Studio 2012 and .NET 4.5 - CodeProject:
and here - about CDatabase and CRecordset issue:
http://stackoverflow.com/questions/12714310/crecordsetsnapshot-doesnt-work-in-vs2012-anymore-whats-the-alternative
in case of huge obj files follow this:
Avoid overriding from Template class , its better to use Proxy pattern , and gave it as a data member.
Lessons learned migrating to Visual Studio 2012 and .NET 4.5 - CodeProject:
and here - about CDatabase and CRecordset issue:
http://stackoverflow.com/questions/12714310/crecordsetsnapshot-doesnt-work-in-vs2012-anymore-whats-the-alternative
One of the major changes in the ODBC that MS did for MFC is
changing the cursor type while opening DB connection.
They change it from SQL_CUR_USE_ODBC
to be SQL_CUR_USE_DRIVER
It seems that while
accessing DB2 db
via MFC/odbc there is no runtime error, when I used MS default
implementation at vs2013(e.g. SQL_CUR_USE_DRIVER), when accessing MSSQL via odbc there are runtime error "feature not implemnted" while trying to update sanpshot CRecordset.
the fix at the moment is as explain in the above link , override the CDatabase OpenEx and use the "old" cursor type SQL_CUR_USE_ODBC.
in case of huge obj files follow this:
Avoid overriding from Template class , its better to use Proxy pattern , and gave it as a data member.
ATL and MFC changes and fixes in Visual Studio 2013
Tuesday, October 22, 2013
C++ Free performance tools
check out this tools :
codersnotes.com - Very Sleepy:
and this one from AMD :
http://developer.amd.com/tools/hc/CodeAnalyst/archive/Pages/default.aspx
another one shinyprofile
http://sourceforge.net/projects/shinyprofiler/
all from here:
http://stackoverflow.com/questions/67554/whats-the-best-free-c-profiler-for-windows-if-there-are
codersnotes.com - Very Sleepy:
and this one from AMD :
http://developer.amd.com/tools/hc/CodeAnalyst/archive/Pages/default.aspx
another one shinyprofile
http://sourceforge.net/projects/shinyprofiler/
all from here:
http://stackoverflow.com/questions/67554/whats-the-best-free-c-profiler-for-windows-if-there-are
Thursday, October 10, 2013
Wednesday, October 9, 2013
Passing jstring to JAVA from C++ - the right way.
hi
i used to use this function
m_env->NewStringUTF(formattedMsg);
and one day i saw that the string i passed in my case it was huge more than 500k, cut in the end.
so i replcae this function with this one ... and its worked !!
jstring WindowsToJstring(JNIEnv* pEnv, LPCTSTR cstr) {
jstring retJstring = NULL;
int slen = strlen(cstr);
int length = MultiByteToWideChar( CP_ACP, 0, (LPCSTR)cstr, slen, NULL, 0 );
unsigned short* tempbuffer = (unsigned short *)malloc( length*2 + 1 );
MultiByteToWideChar( CP_ACP, 0, (LPCSTR)cstr, slen, (LPWSTR)tempbuffer, length );
retJstring = (pEnv)->NewString((jchar*)tempbuffer, length );
free( tempbuffer );
return retJstring;
}
more details could be found here
http://www.anyang-window.com.cn/between-java-and-c-transmission-through-jni-chinese-string-and-hash-issues/
and
http://stackoverflow.com/questions/8258834/sending-utf-chars-to-java-from-c-using-jni
i used to use this function
m_env->NewStringUTF(formattedMsg);
and one day i saw that the string i passed in my case it was huge more than 500k, cut in the end.
so i replcae this function with this one ... and its worked !!
jstring WindowsToJstring(JNIEnv* pEnv, LPCTSTR cstr) {
jstring retJstring = NULL;
int slen = strlen(cstr);
int length = MultiByteToWideChar( CP_ACP, 0, (LPCSTR)cstr, slen, NULL, 0 );
unsigned short* tempbuffer = (unsigned short *)malloc( length*2 + 1 );
MultiByteToWideChar( CP_ACP, 0, (LPCSTR)cstr, slen, (LPWSTR)tempbuffer, length );
retJstring = (pEnv)->NewString((jchar*)tempbuffer, length );
free( tempbuffer );
return retJstring;
}
more details could be found here
http://www.anyang-window.com.cn/between-java-and-c-transmission-through-jni-chinese-string-and-hash-issues/
and
http://stackoverflow.com/questions/8258834/sending-utf-chars-to-java-from-c-using-jni
Thursday, June 6, 2013
Wednesday, June 5, 2013
Microsoft Visual C++ Tips and Tricks
Microsoft Visual C++ Tips and Tricks:
"0xCDCDCDCD Allocated in heap, but not initialized
0xDDDDDDDD Released heap memory.
0xFDFDFDFD "NoMansLand" fences automatically placed at boundary of heap memory. Should never be overwritten. If you do overwrite one, you're probably walking off the end of an array.
0xCCCCCCCC Allocated on stack, but not initialized"
"0xCDCDCDCD Allocated in heap, but not initialized
0xDDDDDDDD Released heap memory.
0xFDFDFDFD "NoMansLand" fences automatically placed at boundary of heap memory. Should never be overwritten. If you do overwrite one, you're probably walking off the end of an array.
0xCCCCCCCC Allocated on stack, but not initialized"
Saturday, March 16, 2013
AXIS C++ - starter kit for client on windows- WS from C++
To call Webservice from C++ (VC6 in may case) consider using AXIS C++ - gSoap is also a good option.
before starting your code , its very important to set the axis c++ correctly, i get many "system exception" until i figure out that i need to set the environment properly.
after downloading your version (axis-c-1.6b-Win32-trace-bin) and extract it.
set the this environment variable:
- AXISCPP_DEPLOY=D:\MyStuff\axis-c++\axis-c-1.6b-Win32-trace-bin\ -- [ your path]
- add %AXISCPP_DEPLOY%\bin to your PATH.
- download - xerces 2.2 , grab the dll from the bin directory and put it in the %AXISCPP_DEPLOY%\bin directory.
- Create file axiscpp.conf at %AXISCPP_DEPLOY%
in the file set the next rows - use full path:
#ClientLogPath is for axis trace - leave empty in case you dont want
ClientLogPath:D:\MyStuff\axis-c++\axis-c-1.6b-Win32-trace-bin\logs\AxisLog.txt
XMLParser:D:\MyStuff\axis-c++\axis-c-1.6b-Win32-trace-bin\bin\AxisXMLParserXerces.dll
Transport_http:D:\MyStuff\axis-c++\axis-c-1.6b-Win32-trace-bin\bin\HTTPTransport.dll
Channel_HTTP:D:\MyStuff\axis-c++\axis-c-1.6b-Win32-trace-bin\bin\HTTPChannel.dll
Channel_HTTP_SSL:D:\MyStuff\axis-c++\axis-c-1.6b-Win32-trace-bin\bin\HTTPSSLChannel.dll
you are done - its configured properly.
to create your C++ classes from WSDL:
- get the wsdl
- open cmd windows
- set the classpath
- e.g set CLASSPATH=D:\MyStuff\axis-c++\axis-c-1.6b-Win32-trace-bin\lib\axis\wsdl2ws.jar;D:\MyStuff\axis-c++\axis-c-1.6b-Win32-trace-bin\lib\axisjava\axis.jar;D:\MyStuff\axis-c++\axis-c-1.6b-Win32-trace-bin\lib\axisjava\commons-discovery.jar;D:\MyStuff\axis-c++\axis-c-1.6b-Win32-trace-bin\lib\axisjava\commons-logging.jar;D:\MyStuff\axis-c++\axis-c-1.6b-Win32-trace-bin\lib\axisjava\jaxrpc.jar;D:\MyStuff\axis-c++\axis-c-1.6b-Win32-trace-bin\lib\axisjava\saaj.jar;D:\MyStuff\axis-c++\axis-c-1.6b-Win32-trace-bin\lib\axisjava\wsdl4j.jar
- run the command
- java org.apache.axis.wsdl.wsdl2ws.WSDL2Ws any_wsdl.wsdl -lc++ -sclient
you should see your header/cpp files in the directory.
happy coding
Yaniv Tzanany
Thursday, August 16, 2012
How to Debug C++ program running on AIX from Windows
great and easy way to debug your running c++ program on aic from windows.
here is the complete video guide.
http://publib.boulder.ibm.com/infocenter/ieduasst/rtnv1r0/index.jsp?topic=/com.ibm.iea.compileraix/compileraix/10.1/Quick_Start_Guide/Launching_a_Debug_Session/player.html
the PDF doc could be found here http://publib.boulder.ibm.com/infocenter/ieduasst/rtnv1r0/topic/com.ibm.iea.compileraix/compileraix/10.1/Quick_Start_Guide/Launching_a_Debug_Session.pdf
Enjoy
Yaniv Tzanany
here is the complete video guide.
http://publib.boulder.ibm.com/infocenter/ieduasst/rtnv1r0/index.jsp?topic=/com.ibm.iea.compileraix/compileraix/10.1/Quick_Start_Guide/Launching_a_Debug_Session/player.html
the PDF doc could be found here http://publib.boulder.ibm.com/infocenter/ieduasst/rtnv1r0/topic/com.ibm.iea.compileraix/compileraix/10.1/Quick_Start_Guide/Launching_a_Debug_Session.pdf
- The IBM Debugger for AIX is Eclipse-based. It is based on the Client/Server architecture. The client, or the User Interface is what you interact with. It is based on Eclipse and all platforms of IBM Debugger products have a similar-looking UI. However, they talk to a different engine. The Debug Engine controls the user’s application. With the help of expression evaluator, it can debug C, C++, Cobol , and PL/I programs. On ZSeries, the engine can also debug high level assembly. The UI calls the engine by establishing a TCP/IP connection to the debugger engine. Users can debug on I-series, TPF mainframe, Z-series, AIX and on Windows®. But before you attempt to launch a debug session, make sure your program is compiled with –g option. Otherwise, no source is displayed. This presentation illustrates how to launch a debug session on Windows.
- There are other options that affect debugging. -qfullpath will affect the ability of the debugger to find source files. -qlinedebug suppresses information on variables. -qtbtable can be used to suppress traceback tables. This can affect the ability of the debugger to build stack traces. -O should not be used. Debugging optimized code is possible, but the results can be misleading. Consult the your compiler documentation for more information.
- This presentation illustrates how to launch a debug session on Windows. On Windows, from Start->All Programs->IBM->IBM Debugger for AIX->IBM Debugger for AIX, you can launch the UI. You can also set a shortcut to the UI program and place it on your desktop and double click the icon. Once the UI is launched, there are several steps to follow in order to launch a debug session.
- Step 1: Select a profile location. Once the debugger is launched, you are prompted for a profile location. This is a place for breakpoint setting, view setting, and any other customization that you have done to the user interface. You can select the check box “Use this as the default and do not ask again” to bypass this dialogue in the future.
- Step 2: Check the Debugger Daemon. By default, the debugger daemon is set to port 8001, you will need to know the number when launching the debug engine. In the UI, under the debugger daemon, circled in red, there are controls that let you: stop listening, change port, and obtain workstation IP. Information provided from these controls is necessary for step 3.
- Step 3: Launching the debugger engine From a telnet/ssh session to the AIX machine where the debugger engine resides, the irmtdbgc –qhost=workstation:port a.out command line will launch the debugger engine. You can also attach to a running process by using the –a flag. Note that if you use the default 8001 port, it is not necessary to specify the port. In the examples here, you are launching the debugger engine to connect to the host sunshine, default port 8001, to debug a program a.out, core file and attach to a process.
- You can also specify the default host and port with the DER_DBG_ADDR environment parameter. For example, you can put the export statement in your profile export DER_DBG_ADDR=host:port And then launch the debugger engine in a simpler way. irmtdbgc a.out will then launch the debugger engine to connect to host sunshine, port 8001 to debug program a.out
Enjoy
Yaniv Tzanany
How to Debug a Release build at C++ - VC6
follow the next steps
http://support.microsoft.com/kb/291585
i have no idea where its came from the next article
http://support.microsoft.com/kb/291585
i have no idea where its came from the next article
Debugging in Release Mode
I've
heard a myth repeated many times by my fellow VC++ developers. It is that it is
not possible to debug in Release Mode. Fortunately, this is a myth.
Rule
7:
When all else fails try debugging in release mode.
It
is possible to debug in Release mode. The first step is to turn on symbols:
- In Project Settings (Alt-F2) under the "C++/C
tab" set the category to "General" and change the Debug
Info setting to "Program Database".
- Under the "Link tab" check the "Generate
Debug Info" tab.
- Recompile using "Rebuild All"
This
will allow you to see the symbols in the release version. You might want to
also consider the following:
- You may want disable your optimization settings when
debugging your release version (though this isn't absolutely necessary).
- If you have trouble placing breakpoints, the command
"__asm {int 3}" will cause your program to stop at that line (be
sure to remove these lines from your program when you are done debugging).
Debugging
in release mode has several limitations.
- The most annoying one is that you can't easily see into
MFC because you don't have the symbols included for the MFC DLL.
- You must add symbols to the release versions of all
libraries and DLL's you wish to debug in your release application.
Thursday, August 9, 2012
GetTickCount Linux Implantation
DWORD GetTickCount(void)
{
timespec time1;
clock_gettime(CLOCK_MONOTONIC, &time1);
return (time1.tv_sec * 1000) + (time1.tv_nsec/1000000);
}
Subscribe to:
Posts (Atom)