extern texture variable declaration not possible in same file

Using a texture reference declared in another file like this works fine via

extern texture<float2, 1> tex;

works fine, but fails to compile if they are in the same file, e.g.:

extern texture<float2, 1> tex;

texture<float2, 1> tex;

which fails with “error: redefinition of …”, which makes it a real pain to use since the extern definition can not be added to some common header.

Well, a correction: it compiles but it does not work at all. So the correct problem report is probably: extern is silently ignored for texture variables.

IMO this might cause someone a real pain, because this behaviour certainly is neither obvious nor expected.

I agree that it not completely obvious. But, the programming guide does say that texture references are implicitly assumed to be static variables at the file scope. Your extern texture will be a different texture reference in each compilation unit because of this.