diff options
| author | ruki <[email protected]> | 2024-04-02 00:58:40 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2024-04-02 00:58:40 +0800 |
| commit | 53a18e3ebc0455166031a8b7aa958825b86a307c (patch) | |
| tree | c846c58f443f14716a18f800bb4eac0921f3984a | |
| parent | d1ee61015c30cd08455b8d9bf85970b4ecaa079a (diff) | |
format tests and templates
19 files changed, 52 insertions, 112 deletions
diff --git a/tests/projects/c++/console/src/main.cpp b/tests/projects/c++/console/src/main.cpp index db2361659..7c775d288 100644 --- a/tests/projects/c++/console/src/main.cpp +++ b/tests/projects/c++/console/src/main.cpp @@ -1,9 +1,6 @@ #include <iostream> -using namespace std; - -int main(int argc, char** argv) -{ - cout << "hello world!" << endl; +int main(int argc, char** argv) { + std::cout << "hello world!" << std::endl; return 0; } diff --git a/tests/projects/c/console/src/main.c b/tests/projects/c/console/src/main.c index 9ae580511..113930e1a 100644 --- a/tests/projects/c/console/src/main.c +++ b/tests/projects/c/console/src/main.c @@ -1,7 +1,6 @@ #include <stdio.h> -int main(int argc, char** argv) -{ +int main(int argc, char** argv) { printf("hello world!\n"); return 0; } diff --git a/xmake/templates/c++/console/project/src/main.cpp b/xmake/templates/c++/console/project/src/main.cpp index 7c435d251..7c775d288 100644 --- a/xmake/templates/c++/console/project/src/main.cpp +++ b/xmake/templates/c++/console/project/src/main.cpp @@ -1,9 +1,6 @@ #include <iostream> -using namespace std; - -int main(int argc, char** argv) -{ - cout << "hello world!" << endl; +int main(int argc, char** argv) { + std::cout << "hello world!" << std::endl; return 0; } diff --git a/xmake/templates/c++/qt.console/project/src/main.cpp b/xmake/templates/c++/qt.console/project/src/main.cpp index de25444ff..e876eea4f 100644 --- a/xmake/templates/c++/qt.console/project/src/main.cpp +++ b/xmake/templates/c++/qt.console/project/src/main.cpp @@ -1,9 +1,7 @@ #include <QCoreApplication> -int main(int argc, char *argv[]) -{ +int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); - printf("hello xmake\n"); return a.exec(); } diff --git a/xmake/templates/c++/qt.quickapp/project/src/main.cpp b/xmake/templates/c++/qt.quickapp/project/src/main.cpp index 2ec4b880c..7d9cb80df 100644 --- a/xmake/templates/c++/qt.quickapp/project/src/main.cpp +++ b/xmake/templates/c++/qt.quickapp/project/src/main.cpp @@ -1,8 +1,7 @@ #include <QGuiApplication> #include <QQmlApplicationEngine> -int main(int argc, char *argv[]) -{ +int main(int argc, char *argv[]) { #if QT_VERSION >= 0x50601 QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); #endif diff --git a/xmake/templates/c++/qt.widgetapp/project/src/main.cpp b/xmake/templates/c++/qt.widgetapp/project/src/main.cpp index b48f94ec8..eb4e26c90 100644 --- a/xmake/templates/c++/qt.widgetapp/project/src/main.cpp +++ b/xmake/templates/c++/qt.widgetapp/project/src/main.cpp @@ -1,11 +1,9 @@ #include "mainwindow.h" #include <QApplication> -int main(int argc, char *argv[]) -{ +int main(int argc, char *argv[]) { QApplication a(argc, argv); MainWindow w; w.show(); - return a.exec(); } diff --git a/xmake/templates/c++/qt.widgetapp/project/src/mainwindow.cpp b/xmake/templates/c++/qt.widgetapp/project/src/mainwindow.cpp index 49d64fce7..57ab27f7d 100644 --- a/xmake/templates/c++/qt.widgetapp/project/src/mainwindow.cpp +++ b/xmake/templates/c++/qt.widgetapp/project/src/mainwindow.cpp @@ -1,14 +1,12 @@ #include "mainwindow.h" #include "ui_mainwindow.h" -MainWindow::MainWindow(QWidget *parent) : - QMainWindow(parent), - ui(new Ui::MainWindow) -{ +MainWindow::MainWindow(QWidget *parent) + : QMainWindow(parent), + ui(new Ui::MainWindow) { ui->setupUi(this); } -MainWindow::~MainWindow() -{ +MainWindow::~MainWindow() { delete ui; } diff --git a/xmake/templates/c++/shared/project/src/main.cpp b/xmake/templates/c++/shared/project/src/main.cpp index ed1924789..d55d4d342 100644 --- a/xmake/templates/c++/shared/project/src/main.cpp +++ b/xmake/templates/c++/shared/project/src/main.cpp @@ -1,9 +1,7 @@ #include "foo.h" #include <iostream> -using namespace std; - int main(int argc, char** argv) { - cout << "add(1, 2) = " << add(1, 2) << endl; + std::cout << "add(1, 2) = " << add(1, 2) << std::endl; return 0; } diff --git a/xmake/templates/c++/static/project/src/main.cpp b/xmake/templates/c++/static/project/src/main.cpp index ed1924789..d55d4d342 100644 --- a/xmake/templates/c++/static/project/src/main.cpp +++ b/xmake/templates/c++/static/project/src/main.cpp @@ -1,9 +1,7 @@ #include "foo.h" #include <iostream> -using namespace std; - int main(int argc, char** argv) { - cout << "add(1, 2) = " << add(1, 2) << endl; + std::cout << "add(1, 2) = " << add(1, 2) << std::endl; return 0; } diff --git a/xmake/templates/c++/tbox.console/project/src/main.cpp b/xmake/templates/c++/tbox.console/project/src/main.cpp index 7af4e5965..8cad00d22 100644 --- a/xmake/templates/c++/tbox.console/project/src/main.cpp +++ b/xmake/templates/c++/tbox.console/project/src/main.cpp @@ -6,15 +6,10 @@ /* ////////////////////////////////////////////////////////////////////////////////////// * main */ -tb_int_t main(tb_int_t argc, tb_char_t** argv) -{ - // init tbox - if (!tb_init(tb_null, tb_null)) return -1; - - // trace - tb_trace_i("hello tbox!"); - - // exit tbox - tb_exit(); +tb_int_t main(tb_int_t argc, tb_char_t** argv) { + if (tb_init(tb_null, tb_null)) { + tb_trace_i("hello tbox!"); + tb_exit(); + } return 0; } diff --git a/xmake/templates/c++/tbox.shared/project/src/_demo/main.cpp b/xmake/templates/c++/tbox.shared/project/src/_demo/main.cpp index 87ee6e396..84dad3f2b 100644 --- a/xmake/templates/c++/tbox.shared/project/src/_demo/main.cpp +++ b/xmake/templates/c++/tbox.shared/project/src/_demo/main.cpp @@ -6,18 +6,11 @@ /* ////////////////////////////////////////////////////////////////////////////////////// * main */ -tb_int_t main(tb_int_t argc, tb_char_t** argv) -{ - // init tbox - if (!tb_init(tb_null, tb_null)) return -1; - - // trace - tb_trace_i("hello tbox!"); - - // test - tb_trace_i("add(1 + 1) = %d", add(1, 1)); - - // exit tbox - tb_exit(); +tb_int_t main(tb_int_t argc, tb_char_t** argv) { + if (tb_init(tb_null, tb_null)) { + tb_trace_i("hello tbox!"); + tb_trace_i("add(1 + 1) = %d", add(1, 1)); + tb_exit(); + } return 0; } diff --git a/xmake/templates/c++/tbox.shared/project/src/_library/interface.cpp b/xmake/templates/c++/tbox.shared/project/src/_library/interface.cpp index a0ccb007b..ab0a826a6 100644 --- a/xmake/templates/c++/tbox.shared/project/src/_library/interface.cpp +++ b/xmake/templates/c++/tbox.shared/project/src/_library/interface.cpp @@ -6,7 +6,6 @@ /* ////////////////////////////////////////////////////////////////////////////////////// * implementation */ -tb_int_t add(tb_int_t a, tb_int_t b) -{ +tb_int_t add(tb_int_t a, tb_int_t b) { return a + b; } diff --git a/xmake/templates/c++/tbox.static/project/src/_demo/main.cpp b/xmake/templates/c++/tbox.static/project/src/_demo/main.cpp index 87ee6e396..84dad3f2b 100644 --- a/xmake/templates/c++/tbox.static/project/src/_demo/main.cpp +++ b/xmake/templates/c++/tbox.static/project/src/_demo/main.cpp @@ -6,18 +6,11 @@ /* ////////////////////////////////////////////////////////////////////////////////////// * main */ -tb_int_t main(tb_int_t argc, tb_char_t** argv) -{ - // init tbox - if (!tb_init(tb_null, tb_null)) return -1; - - // trace - tb_trace_i("hello tbox!"); - - // test - tb_trace_i("add(1 + 1) = %d", add(1, 1)); - - // exit tbox - tb_exit(); +tb_int_t main(tb_int_t argc, tb_char_t** argv) { + if (tb_init(tb_null, tb_null)) { + tb_trace_i("hello tbox!"); + tb_trace_i("add(1 + 1) = %d", add(1, 1)); + tb_exit(); + } return 0; } diff --git a/xmake/templates/c++/tbox.static/project/src/_library/interface.cpp b/xmake/templates/c++/tbox.static/project/src/_library/interface.cpp index a0ccb007b..ab0a826a6 100644 --- a/xmake/templates/c++/tbox.static/project/src/_library/interface.cpp +++ b/xmake/templates/c++/tbox.static/project/src/_library/interface.cpp @@ -6,7 +6,6 @@ /* ////////////////////////////////////////////////////////////////////////////////////// * implementation */ -tb_int_t add(tb_int_t a, tb_int_t b) -{ +tb_int_t add(tb_int_t a, tb_int_t b) { return a + b; } diff --git a/xmake/templates/c/console/project/src/main.c b/xmake/templates/c/console/project/src/main.c index 9ae580511..113930e1a 100644 --- a/xmake/templates/c/console/project/src/main.c +++ b/xmake/templates/c/console/project/src/main.c @@ -1,7 +1,6 @@ #include <stdio.h> -int main(int argc, char** argv) -{ +int main(int argc, char** argv) { printf("hello world!\n"); return 0; } diff --git a/xmake/templates/c/tbox.console/project/src/main.c b/xmake/templates/c/tbox.console/project/src/main.c index 7af4e5965..8cad00d22 100644 --- a/xmake/templates/c/tbox.console/project/src/main.c +++ b/xmake/templates/c/tbox.console/project/src/main.c @@ -6,15 +6,10 @@ /* ////////////////////////////////////////////////////////////////////////////////////// * main */ -tb_int_t main(tb_int_t argc, tb_char_t** argv) -{ - // init tbox - if (!tb_init(tb_null, tb_null)) return -1; - - // trace - tb_trace_i("hello tbox!"); - - // exit tbox - tb_exit(); +tb_int_t main(tb_int_t argc, tb_char_t** argv) { + if (tb_init(tb_null, tb_null)) { + tb_trace_i("hello tbox!"); + tb_exit(); + } return 0; } diff --git a/xmake/templates/c/tbox.shared/project/src/_demo/main.c b/xmake/templates/c/tbox.shared/project/src/_demo/main.c index 87ee6e396..84dad3f2b 100644 --- a/xmake/templates/c/tbox.shared/project/src/_demo/main.c +++ b/xmake/templates/c/tbox.shared/project/src/_demo/main.c @@ -6,18 +6,11 @@ /* ////////////////////////////////////////////////////////////////////////////////////// * main */ -tb_int_t main(tb_int_t argc, tb_char_t** argv) -{ - // init tbox - if (!tb_init(tb_null, tb_null)) return -1; - - // trace - tb_trace_i("hello tbox!"); - - // test - tb_trace_i("add(1 + 1) = %d", add(1, 1)); - - // exit tbox - tb_exit(); +tb_int_t main(tb_int_t argc, tb_char_t** argv) { + if (tb_init(tb_null, tb_null)) { + tb_trace_i("hello tbox!"); + tb_trace_i("add(1 + 1) = %d", add(1, 1)); + tb_exit(); + } return 0; } diff --git a/xmake/templates/c/tbox.shared/project/src/_library/interface.c b/xmake/templates/c/tbox.shared/project/src/_library/interface.c index a0ccb007b..ab0a826a6 100644 --- a/xmake/templates/c/tbox.shared/project/src/_library/interface.c +++ b/xmake/templates/c/tbox.shared/project/src/_library/interface.c @@ -6,7 +6,6 @@ /* ////////////////////////////////////////////////////////////////////////////////////// * implementation */ -tb_int_t add(tb_int_t a, tb_int_t b) -{ +tb_int_t add(tb_int_t a, tb_int_t b) { return a + b; } diff --git a/xmake/templates/c/tbox.static/project/src/_demo/main.c b/xmake/templates/c/tbox.static/project/src/_demo/main.c index 87ee6e396..84dad3f2b 100644 --- a/xmake/templates/c/tbox.static/project/src/_demo/main.c +++ b/xmake/templates/c/tbox.static/project/src/_demo/main.c @@ -6,18 +6,11 @@ /* ////////////////////////////////////////////////////////////////////////////////////// * main */ -tb_int_t main(tb_int_t argc, tb_char_t** argv) -{ - // init tbox - if (!tb_init(tb_null, tb_null)) return -1; - - // trace - tb_trace_i("hello tbox!"); - - // test - tb_trace_i("add(1 + 1) = %d", add(1, 1)); - - // exit tbox - tb_exit(); +tb_int_t main(tb_int_t argc, tb_char_t** argv) { + if (tb_init(tb_null, tb_null)) { + tb_trace_i("hello tbox!"); + tb_trace_i("add(1 + 1) = %d", add(1, 1)); + tb_exit(); + } return 0; } |
