switch project from cpp to c language since cpp has no benefits what so ever and only confuses everything
This commit is contained in:
parent
c6be556d3e
commit
bf3a0ece78
7 changed files with 22 additions and 47 deletions
16
Makefile
16
Makefile
|
|
@ -3,23 +3,23 @@ SRC_DIR = src
|
|||
OBJ_DIR = obj
|
||||
BIN_DIR = bin
|
||||
|
||||
CC = g++
|
||||
CC = gcc
|
||||
LD = ld
|
||||
CXXFLAGS = -Wall -I$(INC_DIR)
|
||||
CFLAGS = -Wall -I$(INC_DIR)
|
||||
LDFLAGS =
|
||||
|
||||
BLACKJACK_SRC = main.cpp process.cpp
|
||||
BLACKJACK_OBJ := $(addprefix $(OBJ_DIR)/,$(patsubst %.cpp,%.o,$(BLACKJACK_SRC)))
|
||||
BLACKJACK_SRC = main.c process.c
|
||||
BLACKJACK_OBJ := $(addprefix $(OBJ_DIR)/,$(patsubst %.c,%.o,$(BLACKJACK_SRC)))
|
||||
BLACKJACK_SRC := $(addprefix $(SRC_DIR)/,$(BLACKJACK_SRC))
|
||||
BLACKJACK_DEPS = process.h
|
||||
BLACKJACK_DEPS := $(addprefix $(INC_DIR)/,$(BLACKJACK_DEPS))
|
||||
|
||||
DUMMY_TARGET_SRC = dummy_target.cpp
|
||||
DUMMY_TARGET_OBJ := $(addprefix $(OBJ_DIR)/,$(patsubst %.cpp,%.o,$(DUMMY_TARGET_SRC)))
|
||||
DUMMY_TARGET_SRC = dummy_target.c
|
||||
DUMMY_TARGET_OBJ := $(addprefix $(OBJ_DIR)/,$(patsubst %.c,%.o,$(DUMMY_TARGET_SRC)))
|
||||
DUMMY_TARGET_SRC := $(addprefix $(SRC_DIR)/,$(DUMMY_TARGET_SRC))
|
||||
|
||||
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp
|
||||
$(CC) $(CXXFLAGS) -c -o $@ $<
|
||||
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c
|
||||
$(CC) $(CFLAGS) -c -o $@ $<
|
||||
|
||||
blackjack: $(BLACKJACK_OBJ) $(BLACKJACK_DEPS)
|
||||
$(CC) $(LDFLAGS) -o $(BIN_DIR)/$@ $(BLACKJACK_OBJ)
|
||||
|
|
|
|||
|
|
@ -1,15 +1,4 @@
|
|||
#pragma once
|
||||
#ifndef __PROCESS_H
|
||||
#define __PROCESS_H
|
||||
|
||||
#include <string>
|
||||
#include <optional>
|
||||
#include <sys/types.h>
|
||||
|
||||
class Process
|
||||
{
|
||||
public:
|
||||
Process(pid_t pid) : pid(pid) {}
|
||||
|
||||
static std::optional<Process> FindByName(std::string name);
|
||||
private:
|
||||
pid_t pid;
|
||||
};
|
||||
#endif
|
||||
|
|
@ -28,7 +28,7 @@ __attribute__((noreturn)) void slave2_job()
|
|||
status("slave2");
|
||||
|
||||
puts("[slave2] will do something each second");
|
||||
while (true)
|
||||
while (1)
|
||||
{
|
||||
__asm__("nop");
|
||||
sleep(1);
|
||||
|
|
@ -40,13 +40,11 @@ __attribute__((noreturn)) void* slave3_job(void*)
|
|||
status("slave3");
|
||||
|
||||
puts("[slave3] will do something each second but in a thread");
|
||||
while (true)
|
||||
while (1)
|
||||
{
|
||||
__asm__("nop");
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int main()
|
||||
8
src/main.c
Normal file
8
src/main.c
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
#include <unistd.h>
|
||||
#include "process.h"
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
|
||||
return 0;
|
||||
}
|
||||
15
src/main.cpp
15
src/main.cpp
|
|
@ -1,15 +0,0 @@
|
|||
#include <iostream>
|
||||
#include "process.h"
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
auto proc = Process::FindByName("dummy_target");
|
||||
if (proc) proc = proc.value();
|
||||
else
|
||||
{
|
||||
fputs("process not found\n", stderr);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
1
src/process.c
Normal file
1
src/process.c
Normal file
|
|
@ -0,0 +1 @@
|
|||
#include "process.h"
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
#include "process.h"
|
||||
|
||||
std::optional<Process> Process::FindByName(std::string name)
|
||||
{
|
||||
return {};
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue