gorgonmeducer / plooc Goto Github PK
View Code? Open in Web Editor NEWProtected Low-overhead Object Oriented Programming with ANSI-C
License: Apache License 2.0
Protected Low-overhead Object Oriented Programming with ANSI-C
License: Apache License 2.0
can be fixed with modification in plooc.h below:
from
#if (!defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L) && !defined(__cplusplus)
#define __IMPLEMENT_EX(__TYPE, __NAME) \
__TYPE __NAME;
#else
#define __IMPLEMENT_EX(__TYPE, __NAME) \
union { \
__TYPE __NAME; \
__TYPE; \
};
#endif
to
#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L
#define __IMPLEMENT_EX(__TYPE, __NAME) \
__TYPE __NAME;
#else
#define __IMPLEMENT_EX(__TYPE, __NAME) \
union { \
__TYPE __NAME; \
__TYPE; \
};
#endif
# define __end_def_class(...)
好像宏里面也没有定义什么东西
IMPLEMENT(INTERFACE)展开后得到
union {
INTERFACE use_as__INTERFACE;
INTERFACE;
};
下面那行的INTERFACE有什么意义吗?
can be fixed with modification in plooc.h below:
from
#if (!defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L) && !defined(__cplusplus)
#define __IMPLEMENT_EX(__TYPE, __NAME) \
__TYPE __NAME;
#else
#define __IMPLEMENT_EX(__TYPE, __NAME) \
union { \
__TYPE __NAME; \
__TYPE; \
};
#endif
to
#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L
#define __IMPLEMENT_EX(__TYPE, __NAME) \
__TYPE __NAME;
#else
#define __IMPLEMENT_EX(__TYPE, __NAME) \
union { \
__TYPE __NAME; \
__TYPE; \
};
#endif
# undef __with_class
# define __with_class(__TYPE, __SRC, ...) \
{ \
class(__TYPE)*_ =(class(__TYPE) *)(__SRC); \
PLOOC_UNUSED_PARAM(_); \
__VA_ARGS__; \
} \
for (class(__TYPE)*_ =(class(__TYPE) *)(__SRC);NULL != _; _ = NULL)
# undef with_class
# define with_class(__TYPE, __SRC, ...) \
__with_class(__TYPE, __SRC, __VA_ARGS__)
# undef __class_internal
# define __class_internal(__SRC, __DES, __TYPE, ...) \
class(__TYPE) *(__DES) = (class(__TYPE) *)(__SRC); \
PLOOC_UNUSED_PARAM(__DES); \
__with_class(__TYPE, (__SRC), __VA_ARGS__)
# undef class_internal
# define class_internal(__SRC, __DES, __TYPE,...) \
__class_internal(__SRC, __DES, __TYPE, __VA_ARGS__)
没有明白 __with_class 这个宏存在的意义是什么, VA_ARGS 需要这个参数是为了什么操作?
我通过宏展开看到def_class 同样会有类的声明 ,即使不是用declare_class 貌似也不会有什么问题。 我的理解是否对?
Github Discussions is a new feature of Github. It's a support forums for users to ask questions. The traditional Issues should be for reporting bugs only. Please consider turning on Github Discussions. Thank you.
black_box
vs simple
vs simple_c90
vs strict
?
I tried to compile byte_queue.c. I copied all the plooc*.h files into example/byte_queue. I compiled it with this simple command:
gcc byte_queue.c -o byte_queue
But it always failed with this error:
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../lib/libmingw32.a(lib64_libmingw32_a-crtexewin.o): in function `main':
C:/M/mingw-w64-crt-git/src/mingw-w64/mingw-w64-crt/crt/crtexewin.c:70: undefined reference to `WinMain'
collect2.exe: error: ld returned 1 exit status
As you can see, I'm on MSYS2 MINGW64. I have no idea why it failed to link the program.
Update: byte_queue.c doesn't have main function, so it's not a program (maybe a library?).
/*! \note You can only use IMPLEMENT when defining INTERFACE. For Implement
* interface when defining class, you should use DEF_CLASS_IMPLEMENT
* instead.
*/
#define __IMPLEMENT(__INTERFACE) __IMPLEMENT_EX( __INTERFACE, \
use_as__##__INTERFACE)
#define IMPLEMENT(__INTERFACE) __IMPLEMENT(__INTERFACE)
/*! \note if you have used INHERIT or IMPLEMENT to define a class / INTERFACE,
you can use OBJ_CONVERT_AS to extract the reference to the inherited
object.
\*/
看注释 IMPLEMENT 是 INTERFACE 用的 ,但是我看代码中貌似INHERIT 用在 INTERFACE , IMPLEMENT 用在CLASS 的继承。 是我理解错误了?
看了example1-3,限于自身水平看了很久,幸亏有参考 帮助。
然后看main.c后,我没get到PLOOC的优势。换句话说main.c很劝退,因为使用并没有多方便,相反做完了复杂的define init、define cfg、 define interface,然后main.c在调用的时候,并不会有多方便简洁,并没有看到什么优势。
可能是我水平太低了吧,或者我找错了库,我希望有个简单的OOC,让我方便继承,方便调用member function,如果方便到不用传this指针就更好了。
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.