Coder Social home page Coder Social logo

plooc's Issues

compile cpp source code(__OOC_CPP__ is defined) failed on arm-none-eabi-g++ 2021.10

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

compile cpp source code(__OOC_CPP__ is defined) failed on arm-none-eabi-g++ 2021.10

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

class_internal / protected_internal 后面跟参数的意义?

#   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 需要这个参数是为了什么操作?

Open Github Discussions

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.

How to compile the examples?

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?).

IMPLEMENT 和 INHERIT 的区别是?


/*! \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 的继承。 是我理解错误了?

缺少使用的example

看了example1-3,限于自身水平看了很久,幸亏有参考 帮助。

然后看main.c后,我没get到PLOOC的优势。换句话说main.c很劝退,因为使用并没有多方便,相反做完了复杂的define init、define cfg、 define interface,然后main.c在调用的时候,并不会有多方便简洁,并没有看到什么优势。

可能是我水平太低了吧,或者我找错了库,我希望有个简单的OOC,让我方便继承,方便调用member function,如果方便到不用传this指针就更好了。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.