C++:
This is just for fun. It doesn't give exactly the expected output, and even fails to be complied by any C++ compiler. However all the desired numbers (from 1 to 1000 skipping every number prime or divisible by 7) can be generated by the compiler through error messages.
WARNING: Don't compile this unless you are using a very powerful PC (eg. that can run smoothly unoptimized bad games like Crysis and even GTA4 under WINE on Linux </lie>) and a robust C++ compiler with correct template-depth settings!
Honestly, I've only tested numbers up to 100 by myself using GCC. You may also change the number 1000 in the source to around 100 to save time and compile.
#define T ;};template<int p
#define E {enum{r
#define S struct
{T,int i>S C E=p%i&&C<p,i-1>::r}T>S C<p,1>E=1}T>S C<1,p>E=0}T>S O E=C<p,p-1>::r};O<p-1> o;int x[r|!(p%7)]T>S O<0>{};O<1000> o;
UPDATE: Actually, you don't need main() at all!