Instantiation of a shaft encoder causing an error

I’m trying to use the old shaft encoders (with 2 three wire chords). As I was trying to instantiate the sensor, I noticed an error. This is how I instantiated the encoder:

vex::encoder enc1 = vex::encoder(Brain.ThreeWirePort.A);

I have the three wire chords plugged into ports A and B on the Brain. Before I added this line, my program is running fine, but once I include the enocder instantiation in the code the brain gives a “Memory Permission Error” when run (it compiles fine). If I take out the line, the error goes away.

I’m not sure how to fix this and want to use the encoder for a competition tomorrow.

see this, you can’t use Brain.ThreeWirePort.A before it has been instantiated.

best to define that in Robot-Config.cpp or create another instance of the ThreeWirePort