Switch to using C++.

This commit is contained in:
Nicolás A. Ortega Froysa 2024-10-09 19:50:53 +02:00
parent ca544e74fa
commit 836daeb69b
10 changed files with 13 additions and 34 deletions

View File

@ -18,8 +18,8 @@ DEBUG=0
INCFLAGS= INCFLAGS=
LDFLAGS=-lsqlite3 LDFLAGS=-lsqlite3
DEFS= DEFS=
CFLAGS=$(INCFLAGS) -std=gnu99 -Wall -Wextra -Wfatal-errors -Werror CFLAGS=$(INCFLAGS) -std=c++11 -Wall -Wextra -Wfatal-errors -Werror
HDRS=src/arg_parse.h src/util.h src/db.h src/cmd.h HDRS=src/arg_parse.hpp src/db.hpp src/cmd.hpp
OBJS=src/main.o src/arg_parse.o src/db.o src/cmd.o OBJS=src/main.o src/arg_parse.o src/db.o src/cmd.o
VERSION=1.0 VERSION=1.0
@ -33,11 +33,11 @@ else
CFLAGS+=-O2 -DNDEBUG CFLAGS+=-O2 -DNDEBUG
endif endif
%.o:%.c $(HDRS) %.o:%.cpp $(HDRS)
$(CC) -c -o $@ $< $(CFLAGS) -DVERSION=\"$(VERSION)\" $(CXX) -c -o $@ $< $(CFLAGS) -DVERSION=\"$(VERSION)\"
menu-helper: $(OBJS) menu-helper: $(OBJS)
$(CC) -o $@ $^ $(LDFLAGS) $(CXX) -o $@ $^ $(LDFLAGS)
.PHONY: clean distclean install .PHONY: clean distclean install

View File

@ -11,8 +11,8 @@ Ensure the `XDG_DATA_HOME` variable is set (e.g. to `$HOME/.local/share`).
To build the program you will require the following dependencies: To build the program you will require the following dependencies:
- A C compiler compatible with GNU99 C (preferably GCC). - A C++ compiler compatible with GNU99 C (preferably GCC).
- SQLite3 C library - SQLite3 C/C++ library
- Make - Make
Once installed, compile the project with the `make` command. Once installed, compile the project with the `make` command.

View File

@ -15,9 +15,8 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "arg_parse.h" #include "arg_parse.hpp"
#include "util.h"
#include <string.h> #include <string.h>
enum cmd_id parse_args(const char *cmd) { enum cmd_id parse_args(const char *cmd) {

View File

@ -15,8 +15,8 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "cmd.h" #include "cmd.hpp"
#include "db.h" #include "db.hpp"
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>

View File

@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "db.h" #include "db.hpp"
#include <sqlite3.h> #include <sqlite3.h>
#include <unistd.h> #include <unistd.h>

View File

@ -18,8 +18,8 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include "arg_parse.h" #include "arg_parse.hpp"
#include "cmd.h" #include "cmd.hpp"
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
enum cmd_id id; enum cmd_id id;

View File

@ -1,20 +0,0 @@
/*
* Copyright (C) 2024 Nicolás Ortega Froysa <nicolas@ortegas.org>
* Nicolás Ortega Froysa <nicolas@ortegas.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#define ARRAY_LEN(arr) (sizeof(arr) / sizeof(arr[0]))