Run-Time Type Identification (RTTI) in C++ with Detailed Examples

Posted on

In this post, we will discuss Run-Time Type Identification (RTTI) in C++, a feature that allows us to obtain type information for objects at runtime. We will explore how RTTI works, its applications, and provide detailed examples to demonstrate its usage using snake_case naming convention. What is Run-Time Type Identification (RTTI)? Run-Time Type Identification (RTTI)
Read more

Why std::vector is the Optimal Choice for Data Structures for Performance in C++

Posted on

In C++ programming, data structures are essential for organizing and manipulating data. When it comes to storing and manipulating data, one data structure stands out above the rest – the std::vector. Efficient Memory Allocation One of the primary benefits of std::vector is its efficient memory allocation. std::vector uses contiguous memory allocation, which means that the
Read more

Release Notes For Linux v2.0

Posted on

This is the release notes for linux release v2.0 (source code: linux-2.0.tar.gz) with format adjusted by removing/replacing tabs/spaces/new lines/formatting marks. This notes document can give us an understanding of the early development of the Linux kernel. The original ASCII formatted version is at the end of this post. Intro This document contains a list of
Read more

Linux Kernel 5.4.72 Release

Posted on

This post summarizes Linux Kernel new features, bugfixes and changes in Linux 5.4.72 Release. Linux 5.4.72 Release contains 23 changes, patches or new features. In total, there are 126,508 lines of Linux source code changed/added in Linux 5.4.72 release compared to Linux 5.4 release. To view the source code of Linux 5.4.72 kernel release online,
Read more

GCC May “Save” You Some Recursive Functions Calls: an Analysis of a Function Call Stack Length Example

Posted on

We know compilers like gcc can do lots smart optimization to make the program run faster. Regarding functions call optimization, gcc can do tail-call elimination to save the cost of allocating a new stack frame, and tail recursion elimination to turn a recursive function to non-recursive iterative one. gcc can even transform some recursive functions
Read more

How to Statically Link OCaml Programs

Posted on

Static linking is preferred for some cases although it has its own various problems. Static building/linking is not always possible for some languages on some platform. For OCaml, the answer to this question is yes. In this post, we will introduce 2 methods to statically linking OCaml: static linking with runtime glibc required and static
Read more

What can we expect in Java update 2019?

Posted on

Java is the most regularly used programming language for the creation of web applications. This high-level programming language develops by the Sun Micro-system. This language was designed for use in the world of internet and known for fastest, secure, and most reliable language of the computing platform. One interesting fact is that Java programmers are
Read more

How to not use concrete types in lambda function parameters in C++11?

Posted on

C++11 requires that lambda function parameters be declared with concrete types. This is sometimes annoying. auto is really nice, especially when the type is complex like std::vector<std::string>::iterator is quite long to type. I know C++14 allows auto in lambda functions. But how to not use concrete types in lambda function parameters in C++11? In C++11,
Read more

How to operator[] access element in a const map in C++?

Posted on

How to operator[] access element in a const map in C++? For example, the compiler will report error on this piece of code: #include <iostream> #include <string> #include <map> std::int64_t count(const std::map<std::string, std::int64_t>& map) { return map[“one”] + map[“two”]; } int main () { std::map<std::string, std::int64_t> map = { {“one”, 1}, {“two”, 2} }; std::cout
Read more

How to install gfortran on CentOS 7?

Posted on

How to install the gfortran fortran compiler on CentOS 7 Linux? gfortran on CentOS 7 is provided in the gcc-gfortran package. You may install it to install gfortran. # yum install gcc-gfortran Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: ftp.cuhk.edu.hk * epel: ftp.cuhk.edu.hk * extras: centos.01link.hk * nux-dextop: li.nux.ro *
Read more

Required packages for building YouCompleteMe for Vim on Fedora 21

Posted on

YouCompleteMe for Vim on Fedora 21 reports this error: [zma@laptop:~/.vim/bundle/YouCompleteMe]$ ./install.sh — The C compiler identification is GNU 4.9.2 — The CXX compiler identification is GNU 4.9.2 — Check for working C compiler: /usr/bin/cc — Check for working C compiler: /usr/bin/cc — works — Detecting C compiler ABI info — Detecting C compiler ABI info
Read more

g++: sorry, unimplemented: non-trivial designated initializers not supported

Posted on

g++ (version g++ (GCC) 4.8.1 20130603 (Red Hat 4.8.1-1)) report: $ g++ -std=c++11 solution.cpp -o sol solution.cpp: In function ‘int main()’: solution.cpp:50:57: sorry, unimplemented: non-trivial designated initializers not supported Stat init_stat {.depth = 0, .moves = tv, .vec = init}; ^ solution.cpp:50:57: sorry, unimplemented: non-trivial designated initializers not supported solution.cpp:50:57: sorry, unimplemented: non-trivial designated initializers
Read more

How to get the assembly code for OCaml code generated by ocamlopt?

Posted on

How to get the native assembly code (e.g. x86-64 asm) for OCaml code generated by the native ocamlopt compiler? To get the assembly code for an OCaml program, add these parameters to ocamlopt: -S -inline 20 -nodynlink An example is as follows. The OCaml program: $ cat not.ml let not x = ((x – 1)
Read more

ANSI C Grammar and ANSI C Grammar Specification in YACC

Posted on

ANSI C is a standardized version of the C programming language that was introduced in 1989 by the American National Standards Institute (ANSI). The ANSI C standard defines the syntax and semantics of the C language, including its grammar. In this post, we will explore the ANSI C grammar in more detail. The ANSI C
Read more

How to Configure the Latest Version of Flash on Firefox for Linux: by the Fresh Player Plugin

Posted on

As you may know, Adobe stopped supporting the NPAPI version of Flash on Linux and the latest NPAPI version of Flash player at version 11.2 released back in 2012 will only receive security fixes. Even the security fixes to the 11.2 version of the Flash Plugin your Firefox is using will end on May 4,
Read more

Statically Linking C and C++ Programs on Linux with gcc

Posted on

Before statically linking you C and C++ programs, you should be aware of the drawbacks of the static linking especially with glibc. There are some good discussions already: with glibc you’re linking static programs which are not really static and some others here and here. That said, you can choose to statically link C and
Read more

x86-64 ISA / Assembly Programming References

Posted on

This post collect the reference resource for x86-64 (also know as Intel 64, AMD 64) ISA / assembly language programming. x86-64 is a 64-bit extension of the Intel x86 instruction set. ==x86-64 Assembly Programming== Introduction to Computer Systems Resources (15-213 Introduction to Computer Systems Resources from CMU) Lots materials for learning machine-level programming on the
Read more