There is a more portable way to do this, like this:
#include <j2k/Fred/Util/RepeatWC.hpp
// Look at this address:
http://j2k.sourceforge.net/src/j2k/Fred/Util/RepeatWC.hpp
// #define REPEAT_WC_10(x) x, x, x, x, x, x, x, x, x, x
// I have a script that generated it up to 160 and then
256,512,1024,2048,4096,8192
// if you need more just tell me and I can generate it up to 1,048,576 if
you want =)
int myArray[10] = { REPEAT_WC_10( 47 ) };
// or even better
#define sz 10
int myArray[ sz ] = { REPEAT_WC( sz, 47 ) };
// Means: Repeat With Comma
#include <iostream.h>
#include <j2k/Fred/Util/RepeatWC.hpp>
/*
There is even better reason to do that try to do this by hand:
50 times the sequence “11, 23, 45, 32, 16, 98, 32, 55”
512 times the sequence “1, 0”
256 times the sequence:
“Fred”, “Georges”, “Alex”, “Nick”, “Pete”, “Igor”, “Mario”, “Randy”
I don’t suggest more than 512 for space and compile time issues.
512 makes your precompiler rushing to its knees… =)
*/
// Those are requires else the compiler will complain
// since commas are separators and the macro
// needs one.
#define DEF1 11, 23, 45, 32, 16, 98, 32, 55
#define DEF2 1, 0
#define DEF3 “Fred”, “Guy”, “Daniel”, “Bill”,
“Pete”, “Igor”, “Mario”, “Randy”
int main() {
// You must call the correct macro and not REPEAT_WC( 50, DEF1 )
// else the precompiler gets totally mix up ! =)
int seq1[ 50 * 8 ] = { REPEAT_WC_50( DEF1 ) };
int seq2[ 512 * 2 ] = { REPEAT_WC_512( DEF2 ) };
const char* seq3[ 256 * 8 ] = { REPEAT_WC_256( DEF3 ) };
// Quite handy tough.
int i = 0;
for( i = 0; i < (508); i++ ) {
cout << seq1 _<< ’ ';
}
cin >> i; // wait for user
for( i = 0; i < (5122); i++ ) {
cout << seq2 << ’ ';
}
cin >> i; // wait for user
for( i = 0; i < (256*8); i++ ) {
cout << seq3 << ’ ';
}
return 0;
}
Sincerly yours,
Fred.
Standard J2K Library for Embedded C++
http://j2k.sourceforge.net/_