Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7855059
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T20:16:12+00:00 2026-06-02T20:16:12+00:00

I have the following code in a header file: #ifndef BUFFER_H #define BUFFER_H #include

  • 0

I have the following code in a header file:

#ifndef BUFFER_H
#define BUFFER_H
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct c_buff
{
    void *buffer;     // data buffer
    void *buffer_end; // end of data buffer
    size_t capacity;  // maximum number of items in the buffer
    size_t count;     // number of items in the buffer
    size_t sz;        // size of each item in the buffer
    void *head;       // pointer to head
    void *tail;       // pointer to tail
};

void cb_init(c_buff *cb, size_t capacity, size_t sz)
{
    cb->buffer = malloc(capacity * sz);
    if(cb->buffer == NULL) {
        // handle error
    }
    cb->buffer_end = (char *)cb->buffer + capacity * sz;
    cb->capacity = capacity;
    cb->count = 0;
    cb->sz = sz;
    cb->head = cb->buffer;
    cb->tail = cb->buffer;
}
#endif

And the following c file

#include <avr/io.h>
#include <avr/interrupt.h>
#include <stdio.h>
#include <common.h>
#include <usart.h>
#include <buffer.h>

struct c_buff usart_buffer;
struct c_buff *usart_buffer_ptr;

cb_init(usart_buffer_ptr, USART_BUFFER_SIZE, sizeof(char));

void initUSART(void) {
    SETBIT(UCSR0A, UDRE0);
    //SETBIT(UCSR0A, U2X0);
    SETBIT(UCSR0C, UCSZ01);
    SETBIT(UCSR0C, UCSZ00);

    UBRR0 = 25;

    SETBIT(UCSR0B, RXCIE0);
    SETBIT(UCSR0B, TXCIE0);
    SETBIT(UCSR0B, RXEN0);
    SETBIT(UCSR0B, TXEN0);
}

ISR(USART_RX_vect) {
    char data;
    data = UDR0;
    UDR0 = data;
}

ISR(USART_TX_vect) {

}

When I try to compile this I get an error that points to this line:

cb_init(usart_buffer_ptr, USART_BUFFER_SIZE, sizeof(char));

And it just says “error: expected ‘)’ before numeric constant”.

Google tells me it’s some kind of preprocessor error. But I don’t see how that could be the case.

I’m new to C so I apologize if it is something totally obvious.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T20:16:17+00:00Added an answer on June 2, 2026 at 8:16 pm

    You can’t have a naked function call at the top level.

    cb_init(usart_buffer_ptr, USART_BUFFER_SIZE, sizeof(char));
    

    is a naked function call. Move that inside main().

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following C Header/Code Example: Header file struct category_info { int id;
Let's say I have the following code: // templateClass.h #ifndef TEMPLATE_CLASS_H #define TEMPLATE_CLASS_H template
Have a look at the following piece of code Header File: class CxUser {
I have a script that generates a csv file using the following code: header('Content-type:
I have the following code in my header file: class Factovisors { public: Factovisors(std::istream&
I have the following code header(Content-Description: File Transfer); header('Content-Type: audio/mp3'); header(Content-Disposition: attachment; filename= .
I have the following code in a header only file. #pragma once class error_code
I have the following deceleration in my header file // 3D Vector typedef struct
I have the following code: #ifndef GOOGLESET_PHP_H #define GOOGLESET_PHP_H zend_class_entry *googleset_ce; #endif /* GOOGLESET_PHP_H
I have the following code <div class=framepage> <header> <script type=text/javascript> function getBaseUrl() { return

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.