Hi guys ..
1)
is there something like that we have a limit upto which we can create a pointer to pointer to pointer..
i.e int ***********P... like this to which extent we can do this

2)
is this allowed
if in file one i declare a global variable
int x = 10;

and in another file file 2 i use it as
extern int x = 20;

and some other function i file 2 i print the value of x;
it would give some error or print the value.. if value then which value 20 or 10

1. nop..
(char) max size = 16 bit
(int) max size = 32 bit
(__intn) max size = 8,16,32,64 bit
(float) max size = 32 bit

2. use static for global variable or global function

static int a = 10;
static void do_something(void);

1. No language defined limits. Obviously, the language implementation (compiler) may declare such limit (don't worry, it's a huge number ;) . For example, VC++ 2008 eats this nightmare:

void*********************************************************************Ooh;

2. It's an error. Any object may been (identically) declared in some places but must have one and only one definition. Initialization is definition. Obviously, the compiler can't detect this error if you place these definitions in different files. A linker must detect double external objects definition...

1. No language defined limits. Obviously, the language implementation (compiler) may declare such limit (don't worry, it's a huge number ;) . For example, VC++ 2008 eats this nightmare:

void*********************************************************************Ooh;

2. It's an error. Any object may been (identically) declared in some places but must have one and only one definition. Initialization is definition. Obviously, the compiler can't detect this error if you place these definitions in different files. A linker must detect double external objects definition...

Obviously, the compiler can't detect this error if you place these definitions in different files.

What is the reason that compiler will not detect this error if it is not in single file?

What is the reason that compiler will not detect this error if it is not in single file?

You got it! The compiler only works with one *.c or *.cpp file at a time and creates object code files such as *.o and *.obj. Its the linker that puts the object files together with other libraries to resolve symbol references and create the executable file.

1) The required minimum limit is 12. Beyond that, you're relying on your implementation. Note that this limit refers to pointer, array, and function declarators combined.

>What is the reason that compiler will not detect this error if it is not in single file?
Because most compilers don't implement static analysis across files. You can get that behavior by utilizing a good lint program in your build process.

>As far as I know the C++ Standard recommends (not requires) minimum 256 indirections.
You're reading the wrong document. This is the C forum.

Oh, I'm sorry, it's true 12 in C... 5.2.4.1 with melancholic "Implementations should avoid imposing fixed translation limits whenever possible".
Thank you.

Dear johnray31, don't worry: if you catch indirection level overflow in C then switch to C++ and go to the same direction with comfort...

>if you catch indirection level overflow in C [...]
Then you have bigger problems than source code translation. :icon_rolleyes:

This article has been dead for over six months. Start a new discussion instead.