Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- -std=c99 -Wall -Wextra -Wpedantic -Wshadow
- */
- /*
- test_inc.h
- ------------
- */
- #ifndef TEST_INC_H
- #define TEST_INC_H
- #define ARR_1_SIZE 10
- #define ARR_2_SIZE 20
- //error: invalid application of ‘sizeof’ to incomplete type ‘int[]’
- //extern int arr_1[];
- extern int arr_1[ARR_1_SIZE];
- extern int arr_2[ARR_2_SIZE];
- int testFnc();
- #endif
- /*
- main.c
- --------
- */
- #include <stdio.h>
- #include <stdlib.h>
- #include "test_inc.h"
- int arr_1[ARR_1_SIZE];
- int arr_2[ARR_2_SIZE];
- int main()
- {
- printf("1: %zu\n", sizeof arr_1 / sizeof *arr_1 );
- printf("2: %zu\n", sizeof arr_2 / sizeof *arr_2 );
- testFnc();
- return 0;
- }
- /*
- file1.c
- ---------
- */
- #include <stdio.h>
- #include <stdlib.h>
- #include "test_inc.h"
- int testFnc()
- {
- printf("1a: %zu\n", sizeof arr_1 / sizeof *arr_1 );
- printf("2a: %zu\n", sizeof arr_2 / sizeof *arr_2 );
- return 0;
- }
- /*
- output:
- 1: 10
- 2: 20
- 1a: 10
- 2a: 20
- */
Advertisement
Add Comment
Please, Sign In to add comment