Hybrid programming-implement C automatic compilation and thrift file to generate definition files

Source: Internet
Author: User

What is hybrid programming?

Hybrid programming refers to the process of developing applications using two or more programming languages. Currently, there are many popular programming languages on the computer. They have their own advantages and disadvantages. hybrid programming can take full advantage of the advantages of various programming languages. The key issue of mixed programming is parameter transfer.

The above is from Baidu encyclopedia.

Simply put, code is written in more than one language.

During Development in Linux, you need to write some makefiles to support C/C ++ development. However, hybrid programming can integrate makefile and code, what are the benefits of doing so? It is not worthwhile to write makefile for a small test file.

Such mixed programming is as follows:

# If 0g ++-o Test 1. cppexit # endif // The main code is written below # include <iostream> using namespace STD; int main () {cout <"Hello word" <Endl; return 0 ;}

You only need to use Sh 1. cpp to generate the test executable file.

The second example is to use hybrid Programming to Implement thrift definition files to generate thrift files:

/*in/ls > /dev/nullNAME=`echo $0 | awk -F '/' '{print $NF}' | sed 's/\./-/g'`  [ -e "${NAME}-dir" ] || mkdir "${NAME}-dir"thrift -out "${NAME}-dir" -gen cpp $0                                                                                                        exit*/namespace cpp izp enum _EFlowType{    TANX        =   0,      BFP         =   1,      IDCLICKS    =   2,      TOTAL_TYPE  =   3   }typedef _EFlowType EFlowTypestruct test{ 1: i32 id;}

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.