The data types whose declarations you present are not "compatible types" as the standard defines the term, and therefore they cannot be used interchangeably. For structure types to be compatible, they must have not only the same member names and types in the same order, but also the same tag. It is on the last point that the two differ.
In particular, your typedef
defines the identifier arguments
as an alias for a tagless structure type with the specified members. Where that identifier is in scope, you can use it as a type name. Indeed, because the structure type to which it refers has no tag, there is no other way to refer to that type.
The other declaration declares a structure type with tag arguments
. Where that declaration is in scope, you can refer to that type as struct arguments
, but not as just arguments
(C++ differs on this point):
struct arguments my_arguments;
my_arguments.width = 5;
// ...
My question is, is it necassary to add this struct arguments in the function since i already declared it in global?
C has no global declarations. It has file-scope declarations, and by default these declare functions and objects with external linkage, which means they can be accessed from anywhere in the program. That's not quite the same thing. Wherever you use either of those types, therefore, a declaration for it must be in scope. One ordinarily puts shared declarations in a header file to make it easy to fulfill such requirements. In any case, a declaration of one of those types does not serve as a declaration of the other.
You could, however, consider making them compatible by tagging the typedefed structure, either in one declaration ...
typedef struct arguments // <--- note the tag here
{
float width, height, start;
unsigned int *pixmap;
} arguments;
... or in two ...
struct arguments
{
float width, height, start;
unsigned int *pixmap;
};
typedef struct arguments arguments;
Either alternative makes arguments
an alias for type struct arguments
.