storage size of 'start' isn't known - c

I have this message error: storage size of 'start' isn't known when I compile my program. The error is here:
struct _timeb start, finish;
I make a header file when I've put declarations and prototypes
#include <stdio.h>
#include <stdlib.h>
#include <sys/timeb.h>
#include <time.h>
In my .c file, I put
#include "image.h"
#include <math.h>

This usually indicates that the description of the mentioned struct has not yet been encountered, and so you are trying to create a variable of a type the compiler doesn't yet know about. Likely you are missing a header:
#include <sys/timeb.h>

Related

implicit declaration of pivot root causing a compiler error

I have been getting these compiler errors when I am trying to create a self-made containers
warning: implicit declaration of function ‘sys_pivot_root’; did you mean ‘SYS_pivot_root’? [-Wimplicit-function-declaration]
TRY (sys_pivot_root(wd, "/dir/oldroot"));
And then I change sys_pivot_root into SYS_pivot_root then the following error message appears.
install_rootg.c:61:9: error: called object is not a function or function pointer
TRY (SYS_pivot_root(wd, "/dir/oldroot"));
and then I look into syscall.h to see if the function exists. I get the following line
asmlinkage long sys_pivot_root (const char __user * new_root, const char __user * put_old)
why am I getting these compiler errors? I haven't been able to resolve this for like a week now.
I include the header files in this exact order.
#define _GNU_SOURCE
#include <errno.h>
#include <stdio.h>
#include <sched.h>
#include <stdlib.h>
#include <sys/wait.h>
#include <sys/mount.h>
#include <sys/stat.h>
#include <limits.h>
#include <sys/syscall.h>
#include <unistd.h>
#include <sys/mman.h>
any help would be appreciated. Thank you in advance!
I figured out, so there isn't such function already defined as pivot_root.
you can just call syscall(SYS_pivot_root, ...
and pivot_root is called.
look at the man page for the usage.

Including this file causes a bunch of unknown type errors [C]

Including main.h in stm32f4xx_hal_uart.h causes issues --> usart_app.h:14:22: error: unknown type name 'USART_Handle_t'; did you mean 'DMA_Handle_t'? -- mainly related to unknown types.
Aren't there easy ways around figuring out issues specific to file includes? cause it's annoying
I suspect stm32f4xx_dma.h is causing trouble since it's being called in main.h and stm32f4xx_hal_uart.h but I wonder wouldn't header guard take care of the 'loop`?
here's what i sort of have:
// --- main.h ---
#include "stm32f4xx_hal.h"
#include "mcp9808.h"
#include "usart_app.h"
#include "stm32f4xx_dma.h"
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
// --- stm32f4xx_hal_uart.h ---"
#include <stdint.h>
#include "stdbool.h"
#include "../Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rcc.h"
#include "stm32f4xx_dma.h"
#include "main.h" // ... adding this causes issues !!
typedef struct {
USART_TypeDef *pUSARTx;
USART_Config_t USART_Config;
USART_State USART_State;
char *txBuffer;
char *rxBuffer;
uint8_t txLength;
uint8_t rxLength;
uint8_t rxSize;
uint8_t dmaTransfer;
uint8_t dmaReception;
DMA_Handle_t *dmaRx;
DMA_Handle_t *dmaTx;
} USART_Handle_t;
// --- stm32f4xx_dma.h ---
#include "stm32f401xe.h"
#include "stm32f4xx_hal.h"```
… I wonder wouldn't header guard take care of the 'loop`?
What header guard? The file contents you show in the question do not have header guards.
If there are header guards, then the problem is that including main.h in stm32f4xx_hal_uart.h causes it to include usart_app.h, and usart_app.h needs the USART_Handle_t defined in stm32f4xx_hal_uart.h, so it includes stm32f4xx_hal_uart.h, but the earlier processing is already past the header guard in stm32f4xx_hal_uart.h, so the guard skips the body of stm32f4xx_hal_uart.h when usart_app.h includes it, so USART_Handle_t is not defined.
To fix that, do not include main.h in stm32f4xx_hal_uart.h.

Getting error unknown type name 'size_t' even though I've included the relevant C libraries and headers

Please find my code below.
I am getting the error "/usr/include/linux/sysctl.h:40:2: error: unknown type name ‘size_t’"
Searching online, the only suggestion is to make sure you have stddef.h included in your code, which I do as can be seem below. There does not appear to be a solution available outside of this fix, which I have tried, so I am currently at a loss as to how to move forward.
Also note, this code is not pretty, but that is not the main issue with this thread. The error I am getting does not look like it is being thrown from a mistake in my code, but I may be wrong.
#include <linux/netfilter_ipv4.h>
#include <linux/netfilter.h>
#include <linux/ip.h>
#include <linux/tcp.h>
#include <sys/types.h>
#include <linux/module.h>
#include <stddef.h>
struct nf_hook_ops{
struct list_head *list;
nf_hookfn *hook;
struct module *owner;
u_int8_t pf;
unsigned int hooknum;
int priority; /* Hooks are ordered in ascending priority. */
};
int nf_register_hook(struct nf_hook_ops *reg);
void nf_unregister_hook(struct nf_hook_ops *reg);
struct nf_hook_ops nfho = {
nfho.hook = hook_func_in,
nfho.hooknum = NF_INET_LOCAL_IN,
nfho.pf = PF_INE,
nfho.priority = NF_IP_PRI_FIRST
};
nf_register_hook(&nfho); // Register the hook
C is parsed strictly top to bottom, and #include does plain old textual inclusion, not anything clever that would qualify for the name of "module import". Therefore, the order of #include directives can matter. In this case, you're getting complaints about a type defined by stddef.h, so you must make sure that stddef.h is included before whatever needs it, which could be (indeed, is) another header file.
I can reproduce the error you're getting with the following two-line source file:
#include <linux/sysctl.h>
#include <stddef.h>
→
$ gcc -fsyntax-only test.c
In file included from test.c:1:0:
/usr/include/linux/sysctl.h:39:2: error: unknown type name ‘size_t’
If I exchange the order of the #include lines,
#include <stddef.h>
#include <linux/sysctl.h>
then there is no error. This is a bug in linux/sysctl.h, but I would not hold my breath for it to be fixed. I recommend moving stddef.h to the very top of the include list.
I can not reproduce the problem with your actual list of includes,
#include <linux/netfilter_ipv4.h>
#include <linux/netfilter.h>
#include <linux/ip.h>
#include <linux/tcp.h>
#include <sys/types.h>
#include <linux/module.h>
#include <stddef.h>
but a gcc -H dump does not show linux/sysctl.h getting pulled in transitively by that set of includes, so probably it's just that I have a different version of the kernel headers on my Linux box than you do.

Looking for 4psa_base.h header file to recompile app_fax.c

I am trying to recompile app_fax.c to app_fax.so (module used by asterisk to send/receive fax under 4PSA system) which needs a header file called 4psa_base.h
The reason I am recompiling this c program is because of a timeout setting inside the program that kills fax calls that last more than 30 minute. what I did was just change that value
I have looked everywhere for this file with no luck. its not anywhere that I can find it.
Is there anyone that may have any clue where to find this file?
Thanks,
Javid
I'm not sure which version of Asterisk you are using, but app_fax (which is not the preferred fax module in Asterisk) depends on spandsp. Looking at the source, it does not include the header file you're referring to:
ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <inttypes.h>
#include <pthread.h>
#include <errno.h>
#include <tiffio.h>
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
#include <spandsp.h>
#include <spandsp/version.h>
#include "asterisk/lock.h"
#include "asterisk/file.h"
#include "asterisk/logger.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/app.h"
#include "asterisk/dsp.h"
#include "asterisk/module.h"
#include "asterisk/stasis.h"
#include "asterisk/stasis_channels.h"
#include "asterisk/format_cache.h"
Is this a custom patch to Asterisk?

Type mismatch in Redeclaration

I have been able to remove almost all errors except these 5 errors in this C program (too long to paste so providing link).
http://codepad.org/AfqrDojN
The errors I receive are as follows:
I am using the following libraries:
#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <dos.h>
#include <conio.h>
What could be the issue?
you are redefining the function remove that is already declared in
#include <stdio.h>
changing the name of your function to (for example) void myremove() will probably solve your problem.

Resources