Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Prog2
/
labor_peldak
/
lab_07
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
17c4292c
authored
Apr 28, 2025
by
Karsa Zoltán István
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'cmake-project' into 'master'
Cmake project See merge request
!1
parents
e1964254
89e5cf5d
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
156 additions
and
14 deletions
+156
-14
Alakzatlab/alakzat2_main.cpp
+1
-1
Alakzatlab/alakzat_main.cpp
+1
-1
Alakzatlab/memtrace.cpp
+16
-10
Alakzatlab/memtrace.h
+18
-2
CMakeLists.txt
+120
-0
No files found.
Alakzatlab/alakzat2_main.cpp
View file @
17c4292c
...
@@ -37,7 +37,7 @@
...
@@ -37,7 +37,7 @@
using
std
::
cout
;
using
std
::
cout
;
using
std
::
endl
;
using
std
::
endl
;
int
main
(
int
argc
,
char
**
argv
)
{
int
main
()
{
#if ELKESZULT >= 3 // van rajztábla
#if ELKESZULT >= 3 // van rajztábla
Rajztabla
tabla
;
Rajztabla
tabla
;
...
...
Alakzatlab/alakzat_main.cpp
View file @
17c4292c
...
@@ -26,7 +26,7 @@
...
@@ -26,7 +26,7 @@
using
std
::
cout
;
using
std
::
cout
;
using
std
::
endl
;
using
std
::
endl
;
int
main
(
int
argc
,
char
**
argv
)
{
int
main
()
{
const
int
N
=
100
;
// maximum 100 alakzatunk lehet
const
int
N
=
100
;
// maximum 100 alakzatunk lehet
Alakzat
*
idom
[
N
];
Alakzat
*
idom
[
N
];
...
...
Alakzatlab/memtrace.cpp
View file @
17c4292c
...
@@ -5,8 +5,9 @@ Keszitette: Peregi Tamas, BME IIT, 2011
...
@@ -5,8 +5,9 @@ Keszitette: Peregi Tamas, BME IIT, 2011
Kanari: Szeberenyi Imre, 2013.
Kanari: Szeberenyi Imre, 2013.
VS 2012: Szeberényi Imre, 2015.,
VS 2012: Szeberényi Imre, 2015.,
mem_dump: 2016.
mem_dump: 2016.
meset felszabaditaskor: 2018.
me
m
set felszabaditaskor: 2018.
typo: 2019.
typo: 2019.
poi_check: 2021.
*********************************/
*********************************/
/*definialni kell, ha nem paracssorbol allitjuk be (-DMEMTRACE) */
/*definialni kell, ha nem paracssorbol allitjuk be (-DMEMTRACE) */
...
@@ -178,7 +179,6 @@ START_NAMESPACE
...
@@ -178,7 +179,6 @@ START_NAMESPACE
dying
=
TRUE
;
dying
=
TRUE
;
exit
(
120
);
exit
(
120
);
}
}
static
void
initialize
();
static
void
initialize
();
END_NAMESPACE
END_NAMESPACE
...
@@ -188,6 +188,7 @@ END_NAMESPACE
...
@@ -188,6 +188,7 @@ END_NAMESPACE
#ifdef MEMTRACE_TO_MEMORY
#ifdef MEMTRACE_TO_MEMORY
START_NAMESPACE
START_NAMESPACE
typedef
struct
_registry_item
{
typedef
struct
_registry_item
{
void
*
p
;
/* mem pointer*/
void
*
p
;
/* mem pointer*/
size_t
size
;
/* size*/
size_t
size
;
/* size*/
...
@@ -197,6 +198,12 @@ START_NAMESPACE
...
@@ -197,6 +198,12 @@ START_NAMESPACE
static
registry_item
registry
;
/*sentinel*/
static
registry_item
registry
;
/*sentinel*/
static
registry_item
*
find_registry_item
(
void
*
p
)
{
registry_item
*
n
=
&
registry
;
for
(;
n
->
next
&&
n
->
next
->
p
!=
p
;
n
=
n
->
next
);
return
n
;
}
static
void
print_registry_item
(
registry_item
*
p
)
{
static
void
print_registry_item
(
registry_item
*
p
)
{
if
(
p
)
{
if
(
p
)
{
print_registry_item
(
p
->
next
);
print_registry_item
(
p
->
next
);
...
@@ -225,6 +232,13 @@ START_NAMESPACE
...
@@ -225,6 +232,13 @@ START_NAMESPACE
}
}
return
0
;
return
0
;
}
}
/* Ellenorzi, hogy a pointer regisztralt-e. Ha nem, akkor 0-val tér vissza */
int
poi_check
(
void
*
pu
)
{
if
(
pu
==
NULL
)
return
1
;
initialize
();
return
find_registry_item
(
P
(
pu
))
->
next
!=
NULL
;
}
END_NAMESPACE
END_NAMESPACE
#endif
/*MEMTRACE_TO_MEMORY*/
#endif
/*MEMTRACE_TO_MEMORY*/
...
@@ -271,14 +285,6 @@ START_NAMESPACE
...
@@ -271,14 +285,6 @@ START_NAMESPACE
return
TRUE
;
return
TRUE
;
}
}
#ifdef MEMTRACE_TO_MEMORY
static
registry_item
*
find_registry_item
(
void
*
p
)
{
registry_item
*
n
=
&
registry
;
for
(;
n
->
next
&&
n
->
next
->
p
!=
p
;
n
=
n
->
next
);
return
n
;
}
#endif
static
void
unregister_memory
(
void
*
p
,
call_t
call
)
{
static
void
unregister_memory
(
void
*
p
,
call_t
call
)
{
initialize
();
initialize
();
#ifdef MEMTRACE_TO_FILE
#ifdef MEMTRACE_TO_FILE
...
...
Alakzatlab/memtrace.h
View file @
17c4292c
...
@@ -5,7 +5,8 @@ Keszitette: Peregi Tamas, BME IIT, 2011
...
@@ -5,7 +5,8 @@ Keszitette: Peregi Tamas, BME IIT, 2011
Kanari: Szeberenyi Imre, 2013.,
Kanari: Szeberenyi Imre, 2013.,
VS 2012: Szeberényi Imre, 2015.,
VS 2012: Szeberényi Imre, 2015.,
mem_dump: 2016.
mem_dump: 2016.
inclue-ok: 2017., 2018., 2019., 2021.
inclue-ok: 2017., 2018., 2019., 2021., 2022.
clang-mágia:Bodor András, 2025
*********************************/
*********************************/
#ifndef MEMTRACE_H
#ifndef MEMTRACE_H
...
@@ -102,6 +103,7 @@ END_NAMESPACE
...
@@ -102,6 +103,7 @@ END_NAMESPACE
#if defined(MEMTRACE_TO_MEMORY)
#if defined(MEMTRACE_TO_MEMORY)
START_NAMESPACE
START_NAMESPACE
int
mem_check
(
void
);
int
mem_check
(
void
);
int
poi_check
(
void
*
);
END_NAMESPACE
END_NAMESPACE
#endif
#endif
...
@@ -160,6 +162,11 @@ END_NAMESPACE
...
@@ -160,6 +162,11 @@ END_NAMESPACE
#include <ostream>
#include <ostream>
#include <stdexcept>
#include <stdexcept>
#include <ctime>
#include <ctime>
#include <random>
#if __cplusplus >= 201103L
#include <iterator>
#include <regex>
#endif
#endif
#endif
#ifdef MEMTRACE_CPP
#ifdef MEMTRACE_CPP
namespace
std
{
namespace
std
{
...
@@ -187,7 +194,6 @@ START_NAMESPACE
...
@@ -187,7 +194,6 @@ START_NAMESPACE
void
mem_dump
(
void
const
*
mem
,
size_t
size
,
FILE
*
fp
=
stdout
);
void
mem_dump
(
void
const
*
mem
,
size_t
size
,
FILE
*
fp
=
stdout
);
END_NAMESPACE
END_NAMESPACE
#endif
/*MEMTRACE_C*/
#endif
/*MEMTRACE_C*/
...
@@ -217,6 +223,16 @@ void operator delete[](void * p, size_t) THROW_NOTHING;
...
@@ -217,6 +223,16 @@ void operator delete[](void * p, size_t) THROW_NOTHING;
void
operator
delete
(
void
*
p
,
int
,
const
char
*
)
THROW_NOTHING
;
void
operator
delete
(
void
*
p
,
int
,
const
char
*
)
THROW_NOTHING
;
void
operator
delete
[](
void
*
p
,
int
,
const
char
*
)
THROW_NOTHING
;
void
operator
delete
[](
void
*
p
,
int
,
const
char
*
)
THROW_NOTHING
;
// clang >= 3.1 esetén vannak warningok, amiket zavar, hogy redefiniálva van a new/delete
#if defined(__clang__) && (__clang_major__ > 3 || \
(__clang_major__ == 3 && __clang_minor__ > 0))
// Csak nagyon drasztikus warning szint mellet jön elő, amikor van rekurzívnak tűnő makró.
// Ilyenek a new és delete alább, hiszen olyan, mintha magukat hívnák, pedig nincs (ilyen)
// rekurzió makró szinten.
# pragma clang diagnostic ignored "-Wdisabled-macro-expansion"
// Bármilyen kulcsszó újradefiniálása esetén pánikol.
# pragma clang diagnostic ignored "-Wkeyword-macro"
#endif
#define new new(__LINE__, __FILE__)
#define new new(__LINE__, __FILE__)
#define delete memtrace::set_delete_call(__LINE__, __FILE__),delete
#define delete memtrace::set_delete_call(__LINE__, __FILE__),delete
...
...
CMakeLists.txt
0 → 100644
View file @
17c4292c
# lab_07 project
#
# Originally created: 2023-04-13.
#
# CMakeLists.txt --
# CMake file a lab_07 projekt fordításához.
# Használat:
# - parancssor: cmake -B _build -S . && cmake --build _build
# - CLion/Visual Studio: Megnyitni a mappát projektként
cmake_minimum_required
(
VERSION 3.18
)
# Debian Bullseye
include
(
CheckCXXCompilerFlag
)
project
(
lab_07
VERSION 1.0.0
LANGUAGES CXX
)
add_library
(
memtrace STATIC
Alakzatlab/memtrace.cpp Alakzatlab/memtrace.h
)
target_compile_features
(
memtrace PRIVATE cxx_std_98
)
target_compile_definitions
(
memtrace PUBLIC MEMTRACE
)
add_library
(
alakzat-common OBJECT
Alakzatlab/alakzat.cpp
Alakzatlab/alakzat.h
Alakzatlab/ellipszis.h
Alakzatlab/haromszog.cpp
Alakzatlab/haromszog.h
Alakzatlab/kor.cpp
Alakzatlab/kor.h
Alakzatlab/pont.cpp
Alakzatlab/pont.h
Alakzatlab/szakasz.cpp
Alakzatlab/szakasz.h
Alakzatlab/szin.cpp
Alakzatlab/szin.h
)
target_link_libraries
(
alakzat-common PUBLIC memtrace
)
add_executable
(
alakzat
Alakzatlab/alakzat_main.cpp
)
add_executable
(
alakzat_rajztabla
Alakzatlab/alakzat2_main.cpp
Alakzatlab/rajztabla.cpp
Alakzatlab/rajztabla.h
)
target_link_libraries
(
alakzat PRIVATE alakzat-common
)
target_compile_features
(
alakzat PRIVATE cxx_std_98
)
set_target_properties
(
alakzat PROPERTIES
CXX_EXTENSIONS OFF
)
target_compile_options
(
alakzat PRIVATE
$<$<CXX_COMPILER_ID:GNU,Clang,AppleClang>:-Werror>
$<$<CXX_COMPILER_ID:MSVC>:/WX>
)
target_link_libraries
(
alakzat_rajztabla PRIVATE alakzat-common
)
target_compile_features
(
alakzat_rajztabla PRIVATE cxx_std_98
)
set_target_properties
(
alakzat_rajztabla PROPERTIES
CXX_EXTENSIONS OFF
)
target_compile_options
(
alakzat_rajztabla PRIVATE
$<$<CXX_COMPILER_ID:GNU,Clang,AppleClang>:-Werror>
$<$<CXX_COMPILER_ID:MSVC>:/WX>
)
## CheckWarningFlag(OptionName CacheName) --
# Ellenőrzi, hogy az használt fordító érti-e a kapott parancssori kapcsolót.
function
(
check_warning_flag OptionName CacheName
)
if
(
OptionName MATCHES
[[^/]]
)
set
(
WarningPrefix
""
)
else
()
set
(
WarningPrefix
"-W"
)
endif
()
check_cxx_compiler_flag
(
"
${
WarningPrefix
}${
OptionName
}
"
"HasWarning_
${
CacheName
}
"
)
set
(
"HAS_WARNING_
${
CacheName
}
"
${
HasWarning_
${
CacheName
}}
PARENT_SCOPE
)
endfunction
()
## generate_warnings(&Target) --
# Beállít hibakapcsolókat a kapott target-en.
function
(
generate_warnings _Target
)
set
(
gw_known_warnings
# GCC/Clang
extra pedantic error=vla error=non-virtual-dtor
parentheses logical-op reorder no-c++98-compat
no-reserved-macro-identifier no-unused-macros no-float-equal
no-global-constructors no-exit-time-destructors no-unsafe-buffer-usage
no-shadow-field-in-constructor no-suggest-override no-old-style-cast
# MSVC
# 'function': member function does not override any base class virtual member function
/we4263
# 'class': class has virtual functions, but destructor is not virtual
/we4265
# 'identifier': illegal qualified name in member declaration
/we4596
# 'symbol': exception specification does not match previous declaration
/we4986
4
/permissive-
/diagnostics:caret
)
# MSVC /Wall == clang -Weverything, arra nincs szükségünk
set
(
gw_found_warnings $<$<CXX_COMPILER_ID:GNU,Clang,AppleClang>:-Wall>
)
foreach
(
warn IN LISTS gw_known_warnings
)
string
(
MAKE_C_IDENTIFIER
"
${
warn
}
"
CacheName
)
check_warning_flag
(
"
${
warn
}
"
${
CacheName
}
)
if
(
HAS_WARNING_
${
CacheName
}
)
if
(
warn MATCHES
[[^/]]
)
set
(
WarningPrefix
""
)
else
()
set
(
WarningPrefix
"-W"
)
endif
()
list
(
APPEND gw_found_warnings
"
${
WarningPrefix
}${
warn
}
"
)
endif
()
endforeach
()
target_compile_options
(
"
${
_Target
}
"
PUBLIC
${
gw_found_warnings
}
)
endfunction
()
generate_warnings
(
alakzat
)
generate_warnings
(
alakzat_rajztabla
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment