Error Correction set (continuous update)

Source: Internet
Author: User

1. Two common compression methods in Linux: (unpack: tar-zxvf + directory to be generated by package name)

Bz2 File

Time tar-jcvf j.tar.bz2 workspace/

340 m 56.8%

Real 13m20. 975 s

User 11m13. 872 s

Sys 0m5. 985 s

GZ File

Time tar-zcvf z.tar.gz workspace/

348 m 58.1%

Real 2m10. 305 S

User 0m54. 228 s

Sys 0m7. 399 s

2. when you need to add an interface or tool to a complete project, you do not have to redefine a new class. Sometimes this will become more cumbersome, you can add several functions to a defined class. This makes it clearer and more clean.

3. A dynamic link library: LDD + program name is used in the program:

        libcurl.so.4 => /usr/lib64/libcurl.so.4 (0x00007ff76c8ad000)

This is a dynamic library of curl. It supports uploading and downloading and reading webpage content. Then, when a encapsulated API is called in the program, the Protocol is not supported, that is, the HTTPS protocol, which is supported through curl-V:

curl 7.14.0 (x86_64-unknown-linux-gnu) libcurl/7.14.0 OpenSSL/1.0.1e zlib/1.2.3 libidn/1.18Protocols: ftp gopher telnet dict ldap http file https ftps Features: IDN IPv6 Largefile NTLM SSL libz 

Then the question arises. Why? Then I checked the library linked to the curl program: LDD curl:

        linux-vdso.so.1 =>  (0x00007fff7dfff000)        libcurl.so.3 => /usr/local/lib/libcurl.so.3 (0x00007f8b77c95000)        libidn.so.11 => /lib64/libidn.so.11 (0x00000036a5000000)        libssl.so.1.0.0 => /usr/local/ssl/lib/libssl.so.1.0.0 (0x00007f8b77a2b000)        libcrypto.so.1.0.0 => /usr/local/ssl/lib/libcrypto.so.1.0.0 (0x00007f8b7764f000)        libdl.so.2 => /lib64/libdl.so.2 (0x000000369b800000)        libz.so.1 => /data/mysql/lib/mysql/libz.so.1 (0x00007f8b77438000)        libc.so.6 => /lib64/libc.so.6 (0x000000369b400000)        /lib64/ld-linux-x86-64.so.2 (0x000000369b000000)        libpthread.so.0 => /lib64/libpthread.so.0 (0x000000369bc00000)        libcrypt.so.1 => /lib64/libcrypt.so.1 (0x000000369e000000)        libnsl.so.1 => /lib64/libnsl.so.1 (0x000000369f000000)        libm.so.6 => /lib64/libm.so.6 (0x000000369c000000)        libfreebl3.so => /lib64/libfreebl3.so (0x000000369dc00000)

Here we can see that the libraries used by the two programs are different, so the problem is solved.

/usr/local/lib/libcurl.so.3 

Copy

/usr/lib64/

Then Link libcurl. so.4 in the directory to libcurl. so.3 to use the correct library, and then ldconfig refreshes the cache. OK.

4. Today, I accidentally deleted a project in eclipse. I panicked and decided to go online to Baidu. I learned that the project can be recovered and my mood calmed down. The method is as follows:

In eclipse, you can restore the deleted files in the project, or restore the deleted content in a Java file like SVN.
If files in the project are deleted, follow these steps:
Right-click a project;
Select Restore from local history;
In "check files to restore from local history:", select the file to be restored.
It should be noted that there should be a cache similar to that in the eclipse recovery file. Such a cache may be limited by time and space. Therefore, if you delete too many files, it may not be restored.

I have learned some lessons over the past few days. I hope I can take a long time!

5. If a program needs to be executed in Linux Shell, when the parameter contains parentheses, such:

Cp a. Text (B). Test

An error is reported during direct use:

-Bash: syntax error near unexpected token '('

Here we need to escape the brackets in two ways:

1. Double quotation marks on both ends of the brackets:

Cp a. Test "(B)". Test

2. Add a slash to the brackets:

Cp a. Test \ (B \). Test

6. Today, the program core dump. It is found through debugging that it is a problem of negative unsigned shaping:

When defining a uint32_t type variable, pay special attention to the negative problem. When a uint32_t type variable is negative, the highest bit is changed to 1, then it will directly become the maximum, so often cause memory overflow, see: http://www.cnblogs.com/tenghoo/archive/2008/06/01/1211663.html

7. when a static map object or static vector object needs to be used in a class, that is, all class objects share one STL object or custom class object, according to the definition of C ++, static objects must be initialized outside the class implementation, but initialization of these types of objects is troublesome. Therefore, there is a solution, instead of defining a static map object in a class, the object is directly defined in the class in vitro. This not only allows the object to be used in the class, but also saves the trouble of initialization. Example:

//a.h#include <iostream>#include <map>using namespace std;class A{    public:        static A *getInstance()        {            static A a;            return &a;        }    private:        A(){}        ~A(){}            public:        void display();};

//a.cpp#include "a.h"static map<int, string>m_testMap;void A::display(){char *str[] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};for(int i = 0; i < 7; ++i)m_testMap[i] = str[i];map<int, string>::iterator iter = m_testMap.begin();for( ; iter != m_testMap.end(); ++iter)cout << iter->second << endl;}int main(){        A::getInstance()->display();        return 0;}

Output result:

MondayTuesdayWednesdayThursdayFridaySaturdaySunday

Note: This class cannot be reentrant, that is, it is not thread-safe.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.