Compare commits
	
		
			2 Commits
		
	
	
		
			26d6118f63
			...
			59951fb602
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 59951fb602 | |||
| dfb19d4a1a | 
@@ -1,14 +1,9 @@
 | 
				
			|||||||
#include "../aliases.h"
 | 
					#include "../aliases.h"
 | 
				
			||||||
 | 
					#include "../helper_macros.h"
 | 
				
			||||||
#include <stdio.h>
 | 
					#include <stdio.h>
 | 
				
			||||||
#include <math.h>
 | 
					#include <math.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define obj(o, m) o.m
 | 
					 | 
				
			||||||
#define stringify(x) #x
 | 
					 | 
				
			||||||
#define printf_spec(PI) stringify(PI)
 | 
					#define printf_spec(PI) stringify(PI)
 | 
				
			||||||
#define typename_concat(C, I) vec##C##I##_t
 | 
					 | 
				
			||||||
#define typename(C, I) typename_concat(C, I)
 | 
					 | 
				
			||||||
#define funcname_concat(B, C, I) vec_##B##_vec##C##I##_t
 | 
					 | 
				
			||||||
#define funcname(B, C, I) funcname_concat(B, C, I)
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
typedef struct {
 | 
					typedef struct {
 | 
				
			||||||
	T x;
 | 
						T x;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,14 +1,10 @@
 | 
				
			|||||||
#include "../aliases.h"
 | 
					#include "../aliases.h"
 | 
				
			||||||
 | 
					#include "../helper_macros.h"
 | 
				
			||||||
#include <stdio.h>
 | 
					#include <stdio.h>
 | 
				
			||||||
#include <math.h>
 | 
					#include <math.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define obj(o, m) o.m
 | 
					#define obj(o, m) o.m
 | 
				
			||||||
#define stringify(x) #x
 | 
					 | 
				
			||||||
#define printf_spec(PI) "%" stringify(PI) ", "
 | 
					#define printf_spec(PI) "%" stringify(PI) ", "
 | 
				
			||||||
#define typename_concat(C, I) vec##C##I##_t
 | 
					 | 
				
			||||||
#define typename(C, I) typename_concat(C, I)
 | 
					 | 
				
			||||||
#define funcname_concat(B, C, I) vec_##B##_vec##C##I##_t
 | 
					 | 
				
			||||||
#define funcname(B, C, I) funcname_concat(B, C, I)
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
typedef struct {
 | 
					typedef struct {
 | 
				
			||||||
	#define VEC(type, name) type name;
 | 
						#define VEC(type, name) type name;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -6,7 +6,7 @@ Exploring different ideas for implementing generics in C.
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
[02_macros](./02_macros) is an implementation that uses simple macros to define 2D and 3D vectors for different data types.
 | 
					[02_macros](./02_macros) is an implementation that uses simple macros to define 2D and 3D vectors for different data types.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[03_xmacros](./03_xmacros) is an implementation that relies on X macros to allow for defining any N-dimensional vector for different data types. In this case, it is only 2D and 3D vectors, but it can be easily expanded to other dimensions.
 | 
					[03_xmacros](./03_xmacros) is an implementation that relies on X macros to allow for defining any N-dimensional vector for different data types. In this case, only 2D and 3D vectors were defined, but it can be easily expanded to other dimensions.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## General assessment of the different techniques
 | 
					## General assessment of the different techniques
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										10
									
								
								helper_macros.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								helper_macros.h
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,10 @@
 | 
				
			|||||||
 | 
					#ifndef HELPER_MACROS_H
 | 
				
			||||||
 | 
					#define HELPER_MACROS_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define stringify(x) #x
 | 
				
			||||||
 | 
					#define typename_concat(C, I) vec##C##I##_t
 | 
				
			||||||
 | 
					#define typename(C, I) typename_concat(C, I)
 | 
				
			||||||
 | 
					#define funcname_concat(B, C, I) vec_##B##_vec##C##I##_t
 | 
				
			||||||
 | 
					#define funcname(B, C, I) funcname_concat(B, C, I)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif // !HELPER_MACROS_H
 | 
				
			||||||
		Reference in New Issue
	
	Block a user