PrevUpHome

How to Use Xpp


Memento

Using xpp as cpp(c++) is very easy and fun, as long as your hands are enough.

hello.xpp

#include <iostream>

class Hello {
public:
	Hello() {std::cout << "Hello!" << std::endl;}
	~Hello() {std::cout << "Bye!" << std::endl;}
};

int main() {
	delete (new Hello);
}

Write Xpp Source: swan.xpp

swan.xpp

#include <iostream>

class Swan {
public:
	Swan()
	{
		std::cout << "Hello, I am a swan!" << std::endl;
	}
};

int main() {
	Swan swan;
}

Compile: msvc (Windows)

using visual studio msvc
C:\tmp>cl /TP swan.xpp
C:\tmp>swan.exe
Hello, I am a swan!

Compile: gcc (Windows msys2, Windows Cygwin, Linux, Haiku, SerenityOS, FreeBSD, NetBSD, OpenBSD)

using gcc
$ gcc -xc++ swan.xpp -lstdc++ -o swan
$ ./swan
Hello, I am a swan!
using g++
$ g++ -xc++ swan.xpp -o swan
$ ./swan
Hello, I am a swan!

Compile: clang (Windows msys2, Windows Cygwin, Linux, Haiku, SerenityOS, FreeBSD, NetBSD, OpenBSD)

using clang
$ clang -xc++ swan.xpp -lc++ -o swan
$ ./swan
Hello, I am a swan!
using clang++
$ clang++ -xc++ swan.xpp -o swan
$ ./swan
Hello, I am a swan!

Last revised: March 04, 2022 at 05:37:35 GMT


PrevUpHome