Preheat your oven to 350°F (175°C) and grease two 9-inch round cake pans.
In a large bowl, whisk together flour, sugar, baking soda, baking powder, cinnamon, and salt.
In another bowl, combine oil, eggs, grated carrots, pineapple, and vanilla.
Gradually mix the wet ingredients into the dry ingredients until just combined.
Fold in chopped walnuts if desired.
Divide the batter evenly between the prepared pans.
Bake for 30-35 minutes or until a toothpick inserted comes out clean.
Let the cakes cool in the pans for 10 minutes, then transfer to wire racks to cool completely.
Frost with cream cheese frosting once cooled.