jobtalle / ccvector Goto Github PK
View Code? Open in Web Editor NEWA vector and matrix math library
A vector and matrix math library
Hi, I just had a look at your project (from stb) and noticed that there are a few possible divisions by 0.
In _CCV_FUNC_MAT_INVERSE if the matrices are not invertible, the determinant will be 0 and therefore 1 / det is not computable.
Also for _CCV_FUNC_MAT_PERSPECTIVE if the user gives unappropriated values, such as angle = 0, aspect = 0 or zNear = zFar, it will lead to other divisions by 0 and therefore a crash.
While giving wrong arguments for _CCV_FUNC_MAT_PERSPECTIVE can be easily avoided by the user, I think it would be better to add asserts.
Just my two cents.
This is a notable library on Sean's list, so I'm sure it is tested thoroughly. Nonetheless, when I compile it via GCC with the below options, I get a whole bunch of warnings.
gcc -std=c99 -Wall -Wextra -Wpedantic -O2 -o main src/main.c -Iinclude -lm
In file included from src/main.c:10:0:
include/ccVector.h:387:26: warning: ISO C99 doesn’t support unnamed structs/unions [-Wpedantic]
struct { ccvType x, y; };
^
include/ccVector.h:395:29: warning: ISO C99 doesn’t support unnamed structs/unions [-Wpedantic]
struct { ccvType x, y; };
^
include/ccVector.h:398:6: warning: ISO C99 doesn’t support unnamed structs/unions [-Wpedantic]
};
^
include/ccVector.h:394:4: warning: union has no named members [-Wpedantic]
union {
^~~~~
include/ccVector.h:399:5: warning: ISO C99 doesn’t support unnamed structs/unions [-Wpedantic]
};
^
include/ccVector.h:401:4: warning: ISO C99 doesn’t support unnamed structs/unions [-Wpedantic]
};
^
include/ccVector.h:405:4: warning: ISO C99 doesn’t support unnamed structs/unions [-Wpedantic]
};
^
include/ccVector.h:392:2: warning: union has no named members [-Wpedantic]
union {
^~~~~
include/ccVector.h:406:3: warning: ISO C99 doesn’t support unnamed structs/unions [-Wpedantic]
};
^
include/ccVector.h:416:31: warning: ISO C99 doesn’t support unnamed structs/unions [-Wpedantic]
struct { ccvType x, y; };
^
include/ccVector.h:418:7: warning: ISO C99 doesn’t support unnamed structs/unions [-Wpedantic]
};
^
include/ccVector.h:420:31: warning: ISO C99 doesn’t support unnamed structs/unions [-Wpedantic]
struct { ccvType z, w; };
^
include/ccVector.h:422:7: warning: ISO C99 doesn’t support unnamed structs/unions [-Wpedantic]
};
^
include/ccVector.h:414:5: warning: struct has no named members [-Wpedantic]
struct {
^~~~~~
include/ccVector.h:423:6: warning: ISO C99 doesn’t support unnamed structs/unions [-Wpedantic]
};
^
include/ccVector.h:428:6: warning: ISO C99 doesn’t support unnamed structs/unions [-Wpedantic]
};
^
include/ccVector.h:413:4: warning: union has no named members [-Wpedantic]
union {
^~~~~
include/ccVector.h:429:5: warning: ISO C99 doesn’t support unnamed structs/unions [-Wpedantic]
};
^
include/ccVector.h:412:3: warning: struct has no named members [-Wpedantic]
struct {
^~~~~~
include/ccVector.h:430:4: warning: ISO C99 doesn’t support unnamed structs/unions [-Wpedantic]
};
^
include/ccVector.h:436:7: warning: ISO C99 doesn’t support unnamed structs/unions [-Wpedantic]
};
^
include/ccVector.h:438:6: warning: ISO C99 doesn’t support unnamed structs/unions [-Wpedantic]
};
^
include/ccVector.h:442:6: warning: ISO C99 doesn’t support unnamed structs/unions [-Wpedantic]
};
^
include/ccVector.h:432:4: warning: union has no named members [-Wpedantic]
union {
^~~~~
include/ccVector.h:443:5: warning: ISO C99 doesn’t support unnamed structs/unions [-Wpedantic]
};
^
include/ccVector.h:431:3: warning: struct has no named members [-Wpedantic]
struct {
^~~~~~
include/ccVector.h:444:4: warning: ISO C99 doesn’t support unnamed structs/unions [-Wpedantic]
};
^
include/ccVector.h:411:2: warning: union has no named members [-Wpedantic]
union {
^~~~~
include/ccVector.h:445:3: warning: ISO C99 doesn’t support unnamed structs/unions [-Wpedantic]
};
^
In file included from src/main.c:10:0:
include/ccVector.h: In function ‘mat2x2Rotate’:
include/ccVector.h:63:31: warning: pointers to arrays with different qualifiers are incompatible in ISO C [-Wpedantic]
#define CCV_MAT_TYPENAME(dim) mat##dim##x##dim
^
include/ccVector.h:42:21: note: in definition of macro ‘CAT2_’
#define CAT2_(a, b) a##b
^
include/ccVector.h:97:43: note: in expansion of macro ‘CAT2’
#define CCV_FUNC_MAT_COPY(dim) CAT2(CCV_MAT_TYPENAME(dim), Copy)
^~~~
include/ccVector.h:97:48: note: in expansion of macro ‘CCV_MAT_TYPENAME’
#define CCV_FUNC_MAT_COPY(dim) CAT2(CCV_MAT_TYPENAME(dim), Copy)
^~~~~~~~~~~~~~~~
include/ccVector.h:476:2: note: in expansion of macro ‘CCV_FUNC_MAT_COPY’
CCV_FUNC_MAT_COPY(dim)(buffer, m); \
^~~~~~~~~~~~~~~~~
include/ccVector.h:631:83: note: in expansion of macro ‘CCV_APPLY_MATRIX’
static inline void CCV_FUNC_MAT_ROTATE(2)(CCV_MAT_TYPENAME(2) m, const ccvType r) CCV_APPLY_MATRIX(2, CCV_FUNC_MAT_SET_ROTATION(2)(multiply, r));
^~~~~~~~~~~~~~~~
include/ccVector.h:63:31: warning: pointers to arrays with different qualifiers are incompatible in ISO C [-Wpedantic]
#define CCV_MAT_TYPENAME(dim) mat##dim##x##dim
^
include/ccVector.h:42:21: note: in definition of macro ‘CAT2_’
#define CAT2_(a, b) a##b
^
include/ccVector.h:101:43: note: in expansion of macro ‘CAT2’
#define CCV_FUNC_MAT_MULTIPLY_MATRIX(dim) CAT2(CCV_MAT_TYPENAME(dim), MultiplyMatrix)
^~~~
include/ccVector.h:101:48: note: in expansion of macro ‘CCV_MAT_TYPENAME’
#define CCV_FUNC_MAT_MULTIPLY_MATRIX(dim) CAT2(CCV_MAT_TYPENAME(dim), MultiplyMatrix)
^~~~~~~~~~~~~~~~
include/ccVector.h:477:2: note: in expansion of macro ‘CCV_FUNC_MAT_MULTIPLY_MATRIX’
CCV_FUNC_MAT_MULTIPLY_MATRIX(dim)(m, buffer, multiply); \
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/ccVector.h:631:83: note: in expansion of macro ‘CCV_APPLY_MATRIX’
static inline void CCV_FUNC_MAT_ROTATE(2)(CCV_MAT_TYPENAME(2) m, const ccvType r) CCV_APPLY_MATRIX(2, CCV_FUNC_MAT_SET_ROTATION(2)(multiply, r));
etc.
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.