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 8853361
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T13:38:02+00:00 2026-06-14T13:38:02+00:00

I was trying to test my code so far, and when compiling a test

  • 0

I was trying to test my code so far, and when compiling a test run I’m getting an error.

Here is my code:

mips_op.h file

#ifndef MIPS_OP_H
#define MIPS_OP_H

typedef enum {
    R, I, J
} op_type;

typedef struct op_instr {
    op_type op_t; // instruction type {R, I, J}
    int opcode : 6; // instruction opcode - 6-bit integer

    // if the instruction type is J
    #if op_t == J

    int address : 26; // address to jump to - 26-bit integer

    #else // if the instruction type is R or I

    int rs : 5; // the output - 5-bit integer
    int rt : 5; // the first operand - 5-bit integer

        #if op_t == R // if instruction type is R

        int rd : 5; // the second operand - 5-bit integer
        int shamt : 5; // the shift amount field - 5-bit integer
        int funct : 6; // the function field

        #endif

        #if op_t == I // if instruction type is R

        int immediate : 16; // the immediate field - 16-bit integer

        #endif

    #endif
};

#endif

and here is main.c file

#include <stdio.h>
#include "mips_op.h"

int main (void) {
    printf("Before instr\n");

    op_instr add;

    printf("After instr\n");

    return 0;
}

and here is the error I’m getting

In file included from main.c:2:0:
mips_op.h:9:10: error: expected ')' before 'op_t'
main.c: In function 'main':
main.c:7:2: error: unknown type name 'op_instr'

What is wrong with my code? Why am I getting this error?

Thanks

EDIT: Fixed the brackets to curly brackets

  • 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-14T13:38:03+00:00Added an answer on June 14, 2026 at 1:38 pm

    Replace the “(” in the struct definition to “{“

    typedef struct op_instr
    **{**
       ...
    **}**
    

    EDIT: You may are having this problem

    “Basically, there’s a complex interaction between ordinary C preprocessor directives, ordinary C language elements, and the inscrutable innards of the Arduino IDE & compiler chain.

    As nearly as I can tell, you can wrap #if whatever around simple declarations and most executable code with impunity, but putting anything more elaborate than that, like a simple typedef struct, inside the conditionals causes bizarre problems.

    In fact, just typedef can cause problems, particularly if you attempt to use the ensuing tag in a function declaration. Don’t even think about anything along these lines:”

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

Sidebar

Related Questions

I'm a student, and I'm trying to write and run some test code for
just trying to test for equality in this piece of code, but getting a
I am trying to test some of these code here http://ha.ckers.org/xss.html on my code.
I am trying to set three variables from a test function. Here's my code
I'm trying to test code around a web service that is not available yet.
I am trying to unit test some code, and I need to to replace
I was trying to add some non-production test code by creating a 3rd partial
I am trying to test some other Python code repeatedly, using all possible combinations
I am trying to test the following JavaScript code, which is meant to keep
I'm trying to write a program to test student code against a good implementation.

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.