-
Notifications
You must be signed in to change notification settings - Fork 384
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve howto
- Loading branch information
Showing
6 changed files
with
510 additions
and
246 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
project_root_dir := $(strip $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))) | ||
|
||
runnable := $(project_root_dir)/ccexample | ||
|
||
include_dir := $(project_root_dir)/incl | ||
object_dir := $(project_root_dir)/objs | ||
source_dir := $(project_root_dir)/src | ||
sources := $(wildcard $(source_dir)/*.c) | ||
objects := $(patsubst $(source_dir)/%.c,$(object_dir)/%.c.o,$(sources)) | ||
depends := $(patsubst $(source_dir)/%.c,$(object_dir)/%.c.d,$(sources)) | ||
|
||
CFLAGS = -MMD -MP -g -std=c99 -Wall | ||
CFLAGS += -I $(include_dir) | ||
|
||
all: $(runnable) | ||
|
||
$(runnable): $(objects) | ||
$(CC) $(LINKFLAGS) $^ -o $@ | ||
|
||
$(objects): $(object_dir)/%.c.o: $(source_dir)/%.c | ||
@mkdir --parents $(object_dir) | ||
$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@ | ||
|
||
.PHONY: clean | ||
clean: | ||
rm --recursive --force $(object_dir) | ||
rm --force $(runnable) | ||
|
||
ifneq ($(filter clean,$(MAKECMDGOALS)),clean) | ||
-include $(depends) | ||
endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#ifndef DIVIDE_H | ||
#define DIVIDE_H | ||
|
||
long divide(long numerator, long denominator); | ||
|
||
#endif // DIVIDE_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#include "divide.h" | ||
|
||
long divide(long numerator, long denominator) | ||
{ | ||
return numerator / denominator; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#include "divide.h" | ||
|
||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
|
||
|
||
int main(int argc, char* argv[]) | ||
{ | ||
long result; | ||
long test_case; | ||
|
||
if(argc < 1) { | ||
printf("Please specify testcase id.\n"); | ||
return 1; | ||
} | ||
if (strcmp(argv[1], "all")) { | ||
test_case = strtol(argv[1], NULL, 10); | ||
// Division by zero, only detected when ctu analysis is on | ||
result = divide(test_case, 0); | ||
} | ||
|
||
return (int)result; | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.